docker container creation failed - docker

i tried to install docker image using below command
docker run --rm -d --net=host -it --name npcit -e IPADDR=172.23.14.254 -e NETMASK=255.255.255.0 -e BROADCAST=172.23.14.255 -e NETWORK=172.23.14.0 -e GATEWAY=172.23.14.1 -e INTERFACESv4=eno1 -v /root/npcit/data/:/opt/npcit/data npcit:latest
i got below error:
docker: Error response from daemon: could not copy source resolv.conf file /etc/resolv.conf to /var/lib/docker/containers/c300f5fad3cfb348fcf17124873dfa23e6a2c1dd7228fb03fb5af8787809a874/resolv.conf: open /etc/resolv.conf: no such file or directory.
can someone please help on this y does it fail

Related

Docker environment variable discrepancy

Working on docker desktop on windows.
docker command from the PowerShell:
docker run -p 80:8080 -d --name demo1 -e SWAGGER_JSON=/custom/swagger.json -v a-data-volume:/custom swaggerapi/swagger-ui
docker command from the Git Bash:
docker run -p 80:8080 -d --name demo2 -e SWAGGER_JSON=/custom/swagger.json -v a-data-volume:/custom swaggerapi/swagger-ui
Issue: The environment variable SWAGGER_JSON is not the same on both containers even though it is set the same way in the command. While demo1 has the correct one, demo2 doesn't.

podman not running container in quay setup in centos9

I am setting up quay in a vm with centos distro. This is the guide I am following: quay deploy guide
once I install Podman I am trying to run first container with below command:
I set up this env variable:
export QUAY=QUAY
and made a dir of same name in home:
mkdir QUAY
once I install Podman I am trying to run first container with below command:
$ sudo podman run -d --rm --name postgresql-quay \
-e POSTGRESQL_USER=quayuser \
-e POSTGRESQL_PASSWORD=quaypass \
-e POSTGRESQL_DATABASE=quay \
-e POSTGRESQL_ADMIN_PASSWORD=adminpass \
-p 5432:5432 \
-v $QUAY/postgres-quay:/var/lib/pgsql/data:Z \
registry.redhat.io/rhel8/postgresql-10:1
and I am getting following error:
sudo podman run -d --rm --name postgresql-quay -e POSTGRESQL_USER=quayuser -e POSTGRESQL_PASSWORD=quaypass -e POSTGRESQL_DATABASE=quay -e POSTGRESQL_ADMIN_PASSWORD=adminpass -p 5432:5432 -v QUAY/postgres-quay:/var/lib/pgsql/data:Z registry.redhat.io/rhel8/postgresql-10:1
Error: error creating named volume "QUAY/postgres-quay": error running volume create option: names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*: invalid argument
The bind mount needs to be specified as an absolute path or a relative path that starts with ./ or ../.
In other words instead of
-v QUAY/postgres-quay:/var/lib/pgsql/data:Z
use
-v ./QUAY/postgres-quay:/var/lib/pgsql/data:Z
(I replaced $QUAY with its value QUAY)

Failed to start docker container after reboot

I am hosting an own registry.
After rebooting the Server my registry container is unable to start.
I used this command to start the registry
docker run -d -p 5000:5000 --name registry -v /var/lib/registry/:/var/lib/registry -v /root/certs:/certs -v /root/auth/:/auth -eEGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt -e REGISTRY_HTTP_ADDR=0.0.0.0:5000 -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH=htpasswd" -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" --restart always registry:2.7.1
After a reboot i get this message when i try "docker start registry":
Error response from daemon: OCI runtime create failed: container with id exists: dfb0bef21bdfc8a89b59498befd37f83513e75527c0beb552e0400df2a2b7c7d: unknown
Error: failed to start containers: registry
Starting a new container works fine.
How can a fix, it and sould the container not start by itself because of "--restart alway"
docker --version
Docker version 18.09.6, build 481bc77
Thx for your help.
Update
Intesting news I have written an init script to to the job,
but the problem is exactly the same. The container exists but isn't started.
If I try to start it, I get the error message from above.
On the boot screen in get this information.
So the docker daemon seam to be not ready.
Do you have any suggestions why?

could pass environment variables to docker container OCI runtime create failed

I'm able to run docker below docker run command and it is working fine.
docker run -it ubuntu bash
When I pass environment variables to the docker container then it is failing.
docker run -it ubuntu -e 'ENV_DEPLOY=dev' -e 'CLUSTER_NAME=MyCluster' bash
The error is
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:296: starting container process caused "exec: \"-e\": executable file not found in $PATH": unknown.
I've tried different variants of the above command but still failing with same error.
docker run -it ubuntu -e ENV_DEPLOY="dev" -e CLUSTER_NAME="MyCluster" bash
docker run -it ubuntu -e ENV_DEPLOY=dev -e CLUSTER_NAME=MyCluster bash
docker run -it ubuntu -e ENV_DEPLOY='dev' -e CLUSTER_NAME='MyCluster' bash
docker run -it ubuntu bash -e ENV_DEPLOY='dev' -e CLUSTER_NAME='MyCluster'
The images that I try to run as containers are all in created status when I do docker ps -a.
Could anyone please help me to resolve this error.
You are writting it in the incorrect order.
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
So you should write:
docker run -it -e 'ENV_DEPLOY=dev' -e 'CLUSTER_NAME=MyCluster' ubuntu bash

Unable to discover docker containers

I am following this tutorial for service discovery http://jasonwilder.com/blog/2014/07/15/docker-service-discovery
Briefly:
I created an etcd host running at x.y.z.d:4001
docker run -d --name etcd -p 4001:4001 -p 7001:7001 coreos/etcd
Created a backend server running a container at backend_serverip:8000 and docker-register
$ docker run -d -p 8000:8000 --name whoami -t jwilder/whoami
$ docker run --name docker-register -d -e HOST_IP=$(hostname --all-ip-addresses | awk '{print $1}') -e ETCD_HOST=x.y.z.d:4001 -v /var/run/docker.sock:/var/run/docker.sock -t jwilder/docker-register
Created another backend server running a container at backend2_serverip:8000 and docker-register
$ docker run -d -p 8000:8000 --name whoami -t jwilder/whoami
$ docker run --name docker-register -d -e HOST_IP=$(hostname --all-ip-addresses | awk '{print $1}') -e ETCD_HOST=x.y.z.d:4001 -v /var/run/docker.sock:/var/run/docker.sock -t jwilder/docker-register
Created a client running docker-discover and an ubuntu image
$ docker run -d --net host --name docker-discover -e ETCD_HOST=10.170.71.226:4001 -p 127.0.0.1:1936:1936 -t jwilder/docker-discover
When I look at the logs to see if containers are being registered I see teh folowing error
2015/07/09 19:28:00 error running notify command: python /tmp/register.py, exit status 1
2015/07/09 19:28:00 Traceback (most recent call last):
File "/tmp/register.py", line 22, in <module>
backends = client.read("/backends")
File "/usr/local/lib/python2.7/dist-packages/etcd/client.py", line 347, in read
self.key_endpoint + key, self._MGET, params=params, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/etcd/client.py", line 587, in api_execute
return self._handle_server_response(response)
File "/usr/local/lib/python2.7/dist-packages/etcd/client.py", line 603, in _handle_ser
etcd.EtcdError.handle(**r)
File "/usr/local/lib/python2.7/dist-packages/etcd/__init__.py", line 184, in handle
raise exc(msg, payload)
etcd.EtcdKeyNotFound: Key not found : /backends
I tried manually creating this directory , I also tried running the containers with privileged option but no luck
The error you are getting is from a bug in the code. The problem is that /backends does not exist in your etcd directory. You can create it yourself by manually by running this:
curl -L http://127.0.0.1:4001/v2/keys/backends -XPUT -d dir=true
Once the directory exists in etcd, you won't get the error anymore.
I created a pull request that fixes the bug and if you want to use the fixed code, you can build your own image:
git clone git#github.com:rca/docker-register.git
cd docker-register
docker build -t docker-register .
Then your command for docker register would look like:
$ docker run --name docker-register -d -e HOST_IP=$(hostname --all-ip-addresses | awk '{print $1}') -e ETCD_HOST=x.y.z.d:4001 -v /var/run/docker.sock:/var/run/docker.sock -t docker-register
Note I simply removed jwilder/ from the image name in the command so it uses your local version.

Resources