Failed to start docker container after reboot - docker

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?

Related

How to get access to the docker cmd from docker container?

I've tried to get access to docker command from a container I got an issue says that
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
the container created using this CMD line :
sudo docker run -p 8080:8080 -p 50000:50000 -v /var/run/docker.sock:/usr/lib/systemd/system/docker.socket --name jenkins-master -d jenkins
Hey Guys the issue was in the socket volume I mean in this section
-v /var/run/docker.sock:/usr/lib/systemd/system/docker.socket
should be change to
-v /var/run/docker.sock:/var/run/docker.sock

Docker container exits after few seconds

I'm executing the following command to mount Hadoop-spark-pig-hive docker container using port mapping,
docker run -p 8088:8088 -p 50070:50070 --name hadoop-spark-pig-hive -v C:\Users\Mr.Semicolon\Desktop\iit:/resource -d suhothayan/hadoop-spark-pig-hive:2.9.2
Just to confirm it is up and running I executed the command docker ps
And it works for a few seconds only and docker container exit without any message. Please can someone suggest why this is happening and how can I solve the issue?
Note: I'm using Windows 10 Home environment and docker version 10.03.13 build 4484c46d9d
As Julien B requested I executed docker logs and got the following log message but still have no idea how to solve this,
/etc/bootstrap.sh: line 9: /usr/local/spark/conf/spark-env.sh: Permission denied
/
* Starting OpenBSD Secure Shell server sshd
...done.
Waiting for hdfs to exit from safemode
Safe mode is OFF
Started
I followed a tutorial and Following command worked for me,
docker run -it -p 8088:8088 -p 50070:50070 --name hadoop-spark-pig-hive -v C:\Users\Mr.Semicolon\Desktop\iit:/resource -d suhothayan/hadoop-spark-pig-hive:2.9.2
According to this notebook,
The -it flag tells docker that it should open an interactive container instance.

Error response from daemon: container is not running?

I am getting an error message 'Error from daemon: container is not running". Why? I started the container in detached mode, so it should be running? I tried the -it flags for interactivity but that did not work. I also tried sleeping docker but that did not work.
sh "docker run -d --name mongocontainer19"
sh "docker exec mongocontainer19 mongo mongodump"
The --name gives container names, which is mongocontainer19 in your case. So, you didn't put the image name there.
The syntax is
$ docker run [OPTIONS] IMAGE
So the command should be like$ docker run -d --name mongocontainer19 MyRedisIMAGE
--name <Your_container_alias> will be considered as an option of the command. -d or -p xx:xx are options as well.

pact-broker docker image is not running after restarting docker machine

I am using Postgres image and past broker image in my docker machine for setting up pact broker.
here are 4 steps that have mentioned :
1.$ docker run --name pactbroker-db -e POSTGRES_PASSWORD=ThePostgresPassword -e POSTGRES_USER=admin -e PGDATA=/var/lib/postgresql/data/pgdata -v /var/lib/postgresql/data:/var/lib/postgresql/data -d postgres
2.$ docker run -it --link pactbroker-db:postgres --rm postgres sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U admin'
3.
CREATE USER pactbrokeruser WITH PASSWORD 'TheUserPassword';
CREATE DATABASE pactbroker WITH OWNER pactbrokeruser;
GRANT ALL PRIVILEGES ON DATABASE pactbroker TO pactbrokeruser;
4. docker run --name pactbroker --link pactbroker-db:postgres -e PACT_BROKER_DATABASE_USERNAME=pactbrokeruser -e PACT_BROKER_DATABASE_PASSWORD=TheUserPassword -e PACT_BROKER_DATABASE_HOST=postgres -e PACT_BROKER_DATABASE_NAME=pactbroker -d -p 80:80 dius/pact_broker
after running this 4 command when I am opening Hal browser in my local system it is working pretty fine. Now I am stopping 2 docker containers pactbroker-db and pactbroker and stopping docker machine.
After sometime I am restarting docker machine and starting the containers by
$docker start pactbroker-db and $docker start pactbroker .
containers are getting started but when opening HAL browser I am getting the error "We're sorry, but something went wrong." screenshot attached.
Is there something wrong when I am starting the docker 2nd time?enter image description here
This has been resolved by using container given in https://github.com/DiUS/pact_broker-docker and using proper environment variables in docker-compose.yml of this project.

Docker meaase saying "another repo already pulling"

I ran the following command in docker:
sudo docker run --name my_mysql -e MYSQL_ROOT_PASSWORD=mysecretpassword -d mysql
When i actually wanted to run the following:
sudo docker run --name my_mysql -e MYSQL_ROOT_PASSWORD=mysecretpassword --volumes-from mydatastore -d mysql
Now after i ran the command(the 1st command) , the only way i could stop it was to close the terminal, soi closed it and then opened the terminal again and ran the second command, I.E.
sudo docker run --name my_mysql -e MYSQL_ROOT_PASSWORD=mysecretpassword --volumes-from mydatastore -d mysql
I get the following message:
"another repository already pulling"(or something similar to this error message ... i just messed up all my docker commands and now i can't seem to re-create this error) , How can i solve this issue ?
Either wait, or restart the docker daemon (probably service docker restart).

Resources