Unable to use 'NSKeyValueObservation' in Swift Docker 5.1.3 - swift

I am attempting to use NSKeyValueObservation in a Swift executable I am running on Docker. I am using the following swift version: 5.1.3
I stripped down everything and I literally just declare in main.swift:
var observer: NSKeyValueObservation?
The error returned is:
/package/Sources/TestPackage/main.swift:30:19: error: use of undeclared type 'NSKeyValueObservation'
var observer: NSKeyValueObservation?
Since the error does not occur locally, my hunch is that Docker is running linux and linux doesn't know about NSKeyValueObservation but this isn't documented anywhere. If so, how do I get around this issue?
The relevant Docker version information is:
Client: Docker Engine - Community
Version: 19.03.5
API version: 1.40
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:22:34 2019
OS/Arch: darwin/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:29:19 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683

Your hunch is correct. NSKeyValueObservation relies on the Objective-C runtime, which does not exist on non-Darwin platforms. You will need to use an alternative, such as some flavor of Rx.

Related

springboot container test failing for testcontainers/ryuk with docker engine 20.10

I am working on springboot app where I am using testcontainers for database tests.
I am getting {"message":"No such image: quay.io/testcontainers/ryuk:0.2.3"} error for docker engine version 20.10.0 and higher. And it is working with version 19.03.15
Below are the configuration of my system
docker engine version
Client: Docker Engine - Community
Version: 20.10.0
API version: 1.41
Go version: go1.13.15
Git commit: 7287ab3
Built: Tue Dec 8 18:59:40 2020
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.0
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: eeddea2
Built: Tue Dec 8 18:57:45 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.12
GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.19.0
GitCommit: de40ad0
My configuration is as below
pom.xml
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>1.10.6</version>
<scope>test</scope>
</dependency>
Springboot class :
#TestConfiguration
#EnableJpaRepositories
public class TestDatabaseInitializer
implements ApplicationContextInitializer<ConfigurableApplicationContext>, DisposableBean {
#Container
public static PostgreSQLContainer postgreSQLContainer =
new PostgreSQLContainer("postgres:10.11")
.withDatabaseName("report")
.withUsername("test-user")
.withPassword("test-password");
#Override
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
postgreSQLContainer.start();
TestPropertyValues.of(
"spring.datasource.url=" + postgreSQLContainer.getJdbcUrl(),
"spring.datasource.username=" + postgreSQLContainer.getUsername(),
"spring.datasource.password=" + postgreSQLContainer.getPassword())
.applyTo(configurableApplicationContext.getEnvironment());
}
#Override
public void destroy() {
if (postgreSQLContainer != null && postgreSQLContainer.isRunning()) {
postgreSQLContainer.stop();
}
}
}
Now when I run mvn clean test it gives me following error.
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:142)
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:117)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:383)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:344)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:125)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:417)
Caused by: org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageNameFuture=java.util.concurrent.CompletableFuture#5833f5cd[Completed normally], imagePullPolicy=DefaultPullPolicy(), dockerClient=LazyDockerClient.INSTANCE)
at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1265)
at org.testcontainers.containers.GenericContainer.logger(GenericContainer.java:600)
at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:311)
... 48 common frames omitted
Caused by: com.github.dockerjava.api.exception.NotFoundException: {"message":"No such image: quay.io/testcontainers/ryuk:0.2.3"}
at org.testcontainers.dockerclient.transport.okhttp.OkHttpInvocationBuilder.execute(OkHttpInvocationBuilder.java:279)
at org.testcontainers.dockerclient.transport.okhttp.OkHttpInvocationBuilder.execute(OkHttpInvocationBuilder.java:263)
at org.testcontainers.dockerclient.transport.okhttp.OkHttpInvocationBuilder.post(OkHttpInvocationBuilder.java:134)
at com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:33)
at com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:13)
at com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21)
at com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35)
at com.github.dockerjava.core.command.CreateContainerCmdImpl.exec(CreateContainerCmdImpl.java:1139)
at org.testcontainers.utility.ResourceReaper.start(ResourceReaper.java:85)
at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:135)
at org.testcontainers.LazyDockerClient.getDockerClient(LazyDockerClient.java:14)
at org.testcontainers.LazyDockerClient.listImagesCmd(LazyDockerClient.java:12)
at org.testcontainers.images.LocalImagesCache.maybeInitCache(LocalImagesCache.java:68)
at org.testcontainers.images.LocalImagesCache.get(LocalImagesCache.java:32)
If I change my docker engine version from 20.10.* to 19.03.15 then it is working fine.
I have install specific docker version using
sudo apt-get install docker-ce=5:19.03.15~3-0~ubuntu-focal docker-ce-cli=5:19.03.15~3-0~ubuntu-focal
Docker version :
Client: Docker Engine - Community
Version: 19.03.15
API version: 1.40
Go version: go1.13.15
Git commit: 99e3ed8919
Built: Sat Jan 30 03:17:01 2021
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.15
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 99e3ed8919
Built: Sat Jan 30 03:15:30 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.12
GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.18.0
GitCommit: fec3683
With this version existing code is working without any error or any missing dependency, and it also download quay.io/testcontainers/ryuk:0.2.3

Docker exits as soon as its run

I am not sure if this is the right platform but I have an issue I have been battling for sometime now and frankly its just driving me crazy and my efforts to google it have not been fruitful either. A mongodb docker exits soon as run, see screenshot:
and upon looking at the containers, i see this:
and docker logs [container] is just empty. Any assistance will be highly appreciated as am currently just don't have any other ideas on how to go about this.
cat /etc/os-release gives the following output:
AME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
And docker version gives the following:
Client: Docker Engine - Community
Version: 20.10.7
API version: 1.41
Go version: go1.13.15
Git commit: f0df350
Built: Wed Jun 2 11:56:24 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.7
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: b0f5bc3
Built: Wed Jun 2 11:54:48 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.6
GitCommit: d71fcd7d8303cbf684402823e425e9dd2e99285d
runc:
Version: 1.0.0-rc95
GitCommit: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
docker-init:
Version: 0.19.0
GitCommit: de40ad0

"docker-compose.yml" version rejected, but why?

My YML file begins like this:
version: "3.7"
services:
... ... etc ... ...
But I get this error:
ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this [...]
However, the Docker is "Ubuntu's latest version!"
$ docker version
Client:
Version: 18.09.7
API version: 1.39
Go version: go1.10.1
Git commit: 2d0083d
Built: Fri Aug 16 14:20:06 2019
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.09.7
API version: 1.39 (minimum version 1.12)
Go version: go1.10.1
Git commit: 2d0083d
Built: Wed Aug 14 19:41:23 2019
OS/Arch: linux/amd64
Experimental: false
$ docker-compose version
docker-compose version 1.17.1, build unknown
docker-py version: 2.5.1
CPython version: 2.7.17
OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
The documentation https://docs.docker.com/compose/compose-file/ says that version 3.7 will work with "18.06.0+" so I really don't understand why I'm getting this message at all. The documentation would suggest that this version of Docker does support (and expect) this version.
It looks like your version of docker-compose is incompatible. The version you are using (1.17.1) only supports a compose file format up to version 3.4. You can view the compatibility matrix in the release notes:
1.17.1 release
You can update docker-compose with the following:
curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
And find more information about docker-compose installation here

Can we access docker images, containers from eclipse

I have requirement from testing to access the docker images and containers via eclipse, since the testing team wants to access docker containers via eclipse.
I am referring to this Link
i was able to configure the same, but was not able to see docker image or containers in eclipse.
I have installed docker on windows 10 on Desktop box.
PS C:\Windows\system32> docker version Client: Docker Engine - Community
Version: 19.03.4
API version: 1.40
Go version: go1.12.10
Git commit: 9013bf5
Built: Thu Oct 17 23:44:48 2019
OS/Arch: windows/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.4
API version: 1.40 (minimum version 1.24)
Go version: go1.12.10
Git commit: 9013bf5
Built: Thu Oct 17 23:55:51 2019
OS/Arch: windows/amd64
Experimental: false
Any help on this
Thanks
Sanjeev Kumar N

how to resolve the docker-compose up command execution

I am trying to test this project https://github.com/saan099/sawtooth-test
But while executing docker-compose up command I found this problem:
ERROR: Version in "./docker-compose.yaml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a version of "2" (or "2.0") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
I have tried to change with another version but I still have the same problem. I would be very grateful please if you could help me please.
Those are my docker version and my docker-composer version:
>>> ~/sawtooth-test $ docker --version
Docker version 1.13.1, build 092cba3
>>> ~/sawtooth-test $ docker-compose version
docker-compose version 1.8.0, build unknown
docker-py version: 1.9.0
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
But when I put this docker-compose --version
>>> ~/sawtooth-test $ docker version
Client:
Version: 1.13.1
API version: 1.26
Go version: go1.6.2
Git commit: 092cba3
Built: Thu Nov 2 20:40:23 2017
OS/Arch: linux/amd64
>>> ~/sawtooth-test $ docker-compose --version
docker-compose version 1.8.0, build unknown
Thank you in advance.
Update the first line of your docker-compose.yml file to say version: '3' instead of version: '2.1'
Here is some more information for you pertaining to Docker-Compose versioning.
https://docs.docker.com/compose/compose-file/compose-versioning/
go and nano to docker-compose.yaml
edit version : '2' to "2"
sudo docker-compose up
finally should fix your issue