My docker container needs to connect to other system via http. so , I have export an REST_BASE_URL in environment variable and pass it on docker run using -e parameter . Unfortunately, I am ending up with below error . Can anybody help me out ?
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"-eREST_BASE_URL=https://some.server.url\": stat -eREST_BASE_URL=https://some.server.url: no such file or directory": unknown.
Solved it using docker-compose.
Below is the sample :
version: '3.1'
services:
receiving:
build: .
restart: always
environment:
- "REST_BASE_URL=http://some.server.url"
ports:
- 8080:8080
Related
I am creating a egress-operator. I have a pod egress-operator-controller-manager created from makefile by command make deploy IMG=my_azure_repo/egress-operator:v0.1. The pod is failing , its showing error in pod description as:
State: Waiting
Reason: RunContainerError
Last State: Terminated
Reason: StartError
Message: failed to create containerd task: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/manager": stat /manager: no such file or directory: unknown
Failed 44s (x3 over 59s) kubelet Error: failed to create containerd task:
OCI runtime create failed: container_linux.go:380: starting container process caused:
exec: "/manager": stat /manager: no such file or directory: unknown
I suspect that in manager.yaml, under command: /manager is executed.Can someone let me know what is going wrong in this manager.yaml and whether /manager is valid under command: in deployment.yaml
Debugging UPDATE
Instead of running Dockerfile, now I just build and run image_azure_repo/egress-operator:v0.1 locally (on same ubuntu 18 VM), When I try to login with: docker exec -it <container_id> /bin/bash, I am getting error :
OCI runtime exec failed: exec failed: container_linux.go:380:
starting container process caused: exec: "/bin/bash": stat /bin/bash:
no such file or directory: unknown
This is similar error what I see in pod description. Instead of /bin/bash , I also tried docker exec with /bin/sh and only sh ; Its giving same error
This should be a mismatch for libc.
Golang uses glibc by default while alpine uses musl.
You could try those to fix it:
Use a base image using glibc
Install glibc in your alpine image
In Dockerfile , the Entrypoint you have mentioned is ENTRYPOINT ["/manager"] but shouldnt it be ENTRYPOINT ["./manager"]
regarding "starting container process caused: exec: "/bin/bash": stat /bin/bash: " , it seems base image does not have /bin/bash it might have just /bin/sh
I have the following docker image built by the next docker-compose
services:
give_sync_test:
image: mongo:4.2.10
restart: always
environment:
MONGO_INITDB_DATABASE: mybase
MONGO_INITDB_ROOT_PASSWORD: admin
MONGO_INITDB_DATABASE: password
ports:
- 27017:27017
which i am using through the following gitlab step :
test:
stage: test
dependencies:
- maven_build_snapshot
image: 'my_image:latest'
before_script:
- apt-get update
- apt-get -y install git
- mongo "mongodb://localhost:27017/mybase" < ./utils/test
the content of utils/test is simply :
use myBase;
no action in this, the real problem is that i'm getting the following error from gitlab-ci :
connecting to:
mongodb://localhost:27017/give?compressors=disabled&gssapiServiceName=mongodb
2020-12-09T14:44:21.828+0000 E QUERY [js] Error: couldn't connect
to server localhost:27017, connection attempt failed: SocketException:
Error connecting to localhost:27017 (127.0.0.1:27017) :: caused by ::
Connection refused : connect#src/mongo/shell/mongo.js:353:17
#(connect):2:6 2020-12-09T14:44:21.830+0000 F - [main]
exception: connect failed 2020-12-09T14:44:21.830+0000 E -
[main] exiting with code 1
I've already try the mongo string with some authentication as well
mongodb://admin:password#localhost:27017/mybase
Does anyone know what i'm doing wrong ?
You should use alias of the services to connect to the containers. In this case, you can access mongo by using this connection string mongodb://admin:password#give_sync_test:27017/mybase
I want to deploy ThingsBoard as a Docker container. I use this image and I try to overwrite some environment variables to get connection with an external Postgres database.
I simply have a Postgres running on localhost:5432 with (empty) database thingsboard, I create the Docker volumes mytb-data and mytb-logs and I launch:
docker run -it -p 9090:9090 -p 1883:1883 -p 5683:5683/udp -v mytb-data:/data -v mytb-logs:/var/log/thingsboard -e SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/thingsboard -e SPRING_DATASOURCE_USERNAME=postgres -e SPRING_DATASOURCE_PASSWORD=<MY_PASSWORD_HERE> --name mytb --restart=always thingsboard/tb-postgres
The container starts, but the logs report the following error:
2020-11-03 07:55:40,480 [main] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - ERROR: relation "admin_settings" does not exist
Position: 152
... [OMITTED]
Caused by: org.postgresql.util.PSQLException: ERROR: relation "admin_settings" does not exist
Position: 152
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:116)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:57)
... 166 common frames omitted
pg_ctl: could not send stop signal (PID: 9): No such process
Any idea why this happens?
The environment variables shall be delimited with quotes '[...]' in Docker launch command.
This is not necessary in Docker Compose.
For Docker, launch
docker run -it -p 9090:9090 -p 1883:1883 -p 5683:5683/udp --name thingsboard --restart always -e SPRING_DATASOURCE_URL='<URL>' -e SPRING_DATASOURCE_USERNAME='<USERNAME>' -e SPRING_DATASOURCE_PASSWORD='<PASSWORD>' thingsboard/tb-postgres
Moreover, I was able to solve the issue using the following configuration (Docker Compose, similar for Docker):
thingsboard:
container_name: thingsboard
image: thingsboard/tb-postgres
restart: always
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://<HOSTNAME>:<PORT>/thingsboard
- SPRING_DATASOURCE_USERNAME=<USERNAME>
- SPRING_DATASOURCE_PASSWORD=<PASSWORD>
ports:
- '9090:9090'
- '1883:1883'
- '5683:5683/udp'
Inside mytb-data is created the postgres folder call db, or if you have the db postgres folder in another place do the next in that place.
I consider you have DB folder in the ...mytb-data/db you have to do the next:
chown -R postgres mytbpe-data/db
Because the folder db is created with another user and is the user postgres who is going to use that folder, with this most probably you will fix the problem, I had the same problem and with this I fixed it.
I am trying to create test container with DockerComposeContainer.
DockerComposeContainer container =
new DockerComposeContainer(
new File("src/integrationTest/resources/mycompose-file.yml"))
.withLocalCompose(true)
.withExposedService("mongodb", 27017, Wait.forListeningPort());
container.start();
return container;
mycopose-file.yml has following:
version: '3'
services:
mongodb:
image: mongo:3.6
environment:
MONGO_INITDB_ROOT_USERNAME: uname
MONGO_INITDB_ROOT_PASSWORD: upass
My test dependency include: testcontainers-1.12.3.jar
I am getting error during application context startup:
java.lang.IllegalStateException: Failed to load ApplicationContext
with root cause:
Caused by: org.testcontainers.containers.ContainerLaunchException: Local Docker Compose exited abnormally with code 1 whilst running command: up -d
at org.testcontainers.containers.LocalDockerCompose.invoke(DockerComposeContainer.java:711)
....
In my case I got this error because network in docker had exhausted. Given docker has limited network that we can have. We have to do the cleanup, for that I ran command:
docker network prune
this fixed my problem
I'm trying to execute command after docker container start.
Here is my Dockerfile
FROM mysite:myport/mongo:3.6
EXPOSE 27017
ADD mongo.js /data/mongodb/scripts/
here is my docker-compose.yml
mongo:
image: test-mongo
container_name: test-mongo
hostname: mongo
expose:
- "27017"
ports:
- "27017:27017"
command: mongo --eval load("/data/mongodb/scripts/mongo.js")
docker-compose --no-ansi up returns me
Creating test-mongo ...
Creating test-mongo ... done
Attaching to test-mongo
test-mongo | MongoDB shell version v3.6.5
test-mongo | connecting to: mongodb://127.0.0.1:27017
test-mongo | 2018-06-09T15:46:50.229+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), rea
son: Connection refused
test-mongo | 2018-06-09T15:46:50.229+0000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
test-mongo | connect#src/mongo/shell/mongo.js:251:13
test-mongo | #(connect):1:6
test-mongo | exception: connect failed
test-mongo exited with code 1
I don't uderstand how can I load my file after mongodb is started
By passing a command in your docker-compose.yaml, you are overriding the normal behavior of the mongo image -- so the mongo server is never starting. The way you would typically handle this is to put your script into a second image, and then start a second container as part of your docker-compose.yaml that makes a network connection to the mongo server. Something like:
version: "3"
services:
mongo:
image: mongo
client:
image: my-mongo-client
restart: on-failure
command: mongo --host mongo --eval load("/data/mongodb/scripts/mongo.js")
The restart directive will cause the client container to restart
automatically on failure, which is necessary because it may try to
connect before the mongo server is available to handle connections.
If all you're trying to do is initialize a new database, such as creating a new schema and adding a user, you can create an initialization script and load it into the container. From the Docker Hub documentation:
When a container is started for the first time it will execute files with extensions .sh and .js that are found in /docker-entrypoint-initdb.d. Files will be executed in alphabetical order. .js files will be executed by mongo using the database specified by the MONGO_INITDB_DATABASE variable, if it is present, or test otherwise. You may also switch databases within the .js script.