Error response from daemon: container is not running? - docker

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.

Related

docker run - autokill container already in use?

I was following this guide on customizing MySQL databases in Docker, and ran this command multiple times after making tweaks to the mounted sql files:
docker run -d -p 3306:3306 --name my-mysql -v /Users/pneedham/dev/docker-testing/sql-scripts:/docker-entrypoint-initdb.d/ -e MYSQL_ROOT_PASSWORD=supersecret -e MYSQL_DATABASE=company mysql
On all subsequent executions of that command, I would see an error like this:
docker: Error response from daemon: Conflict. The container name "/my-mysql" is already in use by container "9dc103de93b7ad0166bb359645c12d49e0aa4a3f2330b5980e455cec24843663". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
What I'd like to know is whether that docker run command can be modified to auto-kill the previous container (if it exists)? Or if there is a different command that has the same desired result.
If I were to create a shell script to do that for me, I'd first run docker ps -aqf "name=mysql" and if there is any output, use that resulting container ID by running docker rm -f $containerID. And then run the original command.
docker run command has a --rm arguments that deletes the container after the run is completed. see the docs . So, just change your command to
docker run --rm -d -p 3306:3306 --name my-mysql -v /Users/pneedham/dev/docker-testing/sql-scripts:/docker-entrypoint-initdb.d/ -e MYSQL_ROOT_PASSWORD=supersecret -e MYSQL_DATABASE=company mysql

Error message when creating docker container

I'm trying to create a new docker container using the following command:
docker run -d -it --name compsci -v /c/Users/garre/Documents/CPSC_Courses:/homechapmanfse/computing-resources:cs_base
However, it gives me this error message:
"docker run" requires at least 1 argument.
See 'docker run --help'.
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command in a new container
How would I fix this?
You have to provide the name of the image that you want to run. This is currently missing in your command.
For example, if I were to run mysql, I would execute this:
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql
See the last argument, mysql? That is the name of the image.
Think that you it has build image in your machine. You must inform name of image run.
docker run image-name
This command --name is necessary only you specific name for your container. And the -it command must be entered only when entering the executed container.
docker run -d -it -v
/c/Users/garre/Documents/CPSC_Courses:/homechapmanfse/computing-resources:cs_base
--name 'the name you want to give' 'official name of the image'

Attach to a container generating an exception

I have a docker container that is exiting prematurely due to an exception. I want to connect to it to debug the issue but I can't seem to keep it running in order to connect to it.
This is my initial run command:
docker run -p 8080:80 --env-file=Environment/secret.env --name starter1 starterapp
If I try:
docker attach starter1
It gives:
You cannot attach to a stopped container, start it first
If I try:
docker start -ai starter1
It starts but gives me the exception and exits.
If I try:
docker exec -i -t starter1 /bin/bash
I get:
Error response from daemon: Container 87ac5aade2d298c113bd31b50944b5095601eafc6fe29aebc046eacc76c5c2c9 is not running
I also tried:
docker run -it --rm starterapp /bin/bash -i
But it still dumps out after exception and doesn't open bash command prompt.
How do I get into a bash shell to debug the issue? The exception is generated from kestrel (webserver) due to a missing value so I should be able to access the bash prompt issue free I just cant keep it running so I can't attach to it.
Override the entrypoint with the --entrypoint parameter. You can do something like:
docker run -p 8080:80 -ti --env-file=Environment/secret.env --name starter1 --entrypoint /bin/bash starterapp

How to find/access /var/log/jasmin inside container

I have created by container with docker with the name jasmin_01 using the command
docker run -d -p 1401:1401 -p 2775:2775 -p 8990:8990 --name jasmin_01 jookies/jasmin:latest
Now, i am trying to access log files located in /var/log/jasmin inside the container by running
docker run -d -v /home/user/jasmin_logs:/var/log/jasmin --name jasmin_01 jookies/jasmin:latest
and i am getting the error
Error response from daemon: Conflict. The container name "/jasmin_01" is already in use by container "6bc05cf61a03b74f2b18d05378048e201e3f6ded768ddaf3f2660c39f9d76888". You have to remove (or rename) that container to be able to reuse that name.
How do i solve this please ?
It conflict cause container name jasmin_01 is already in use. You can check it by docker ps -a. For resolve this problem is:
docker stop jasmin_01
docker rm $(docker ps -a -q)
docker run -d -v /home/user/jasmin_logs:/var/log/jasmin --name jasmin_01 jookies/jasmin:latest
Or easiest way is change you new container name
docker run -d -v /home/user/jasmin_logs:/var/log/jasmin --name jasmin_02 jookies/jasmin:latest
The error is quite indicative of the issue: you are trying to start a new container with the same name (jasmin01). Add a unique name, stop the existing container, or remove the --name so that Docker would create a unique name automatically.
docker run --name foo runs a new container named foo
So, if you try to do it twice, you'll indeed get a duplicate name error, as you see
You probably want docker exec:
$ docker help exec
Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
Run a command in a running container
e.g. docker exec jasmine_01 cat /var/log/jasmine/jasmine.log

Error response from daemon: Container CONTAINER_NAME is not running

I have a docker image dajobe/hbase and its been built from Ubuntu. I created a container of this image and named it hb.
$ docker run -d --name hb dajobe/hbase
e1f68ff8b3b6c5e474426e2566f8c087d6a785fc5eeb58cd2aeb86176068651d
I then started the /bin/bash on hb, and checked for the availability of the vi editor.
$ docker exec -it hb /bin/bash
root#e1f68ff8b3b6:/# vi
bash: vi: command not found
I then installed vi editor using apt-get
# apt-get install vim
Reading package lists...
DoneBuilding dependency tree
Reading state information... Done
.....
.....
I wanted to commit the changes so that vi editor could persist.
$ docker commit hb dajobe/hbase
1be196188efc5a52562dc8ee1b63d0fd560ea163c49331c10dc435848d75ef64
then, when i again started dajobe/hbase, it automatically stopped.
$ docker run -d --name hb dajobe/hbase
c3e7b9f48077ef854efc6f9bab5e85986e265c98de5423bece0000c973206c38
$ docker exec -it hb /bin/bash
FATA[0000] Error response from daemon: Container hb is not running
Why is the container not running ?
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c3e7b9f48077 dajobe/hbase:latest "/opt/hbase-server" 11 secs ago Exited (0) 8 secs ago hb
Why is the status "Exited" ? Before committing, this wasn't the case, the status was "Up".
I would expect the status to be Exited. Perhaps the original image you were using had an ENTRYPOINT that did something that kept the container running while you exec'ed to it. You can try this:
docker run -d --name hb dajobe/hbase sleep 60
Then try your exec, for the next 60 seconds you will connect with your interactive shell. After that, you will get the same message again.
The -d makes the container a daemon. It needs something to do, though, otherwise it just exits! Have you tried just doing the run line with the -it?
docker run -it --name hb dajobe/hbase bash
You get a shell prompt there, too, where you can make your updates to the image.
-g
In my case, it solved starting the container again, as easy as it may sound.
Search for the container name with docker ps -a (column "NAMES") if you do not know it; in your case it is known: "hb".
Then docker start hb.
Then docker exec -it hb /bin/bash.
You have used run and not start when you wanted to start an already existing but exited container. I do not see any start in your commands.
then, when i again started dajobe/hbase, it automatically stopped.
$ docker run -d --name hb dajobe/hbase
c3e7b9f48077ef854efc6f9bab5e85986e265c98de5423bece0000c973206c38
$ docker exec -it hb /bin/bash FATA[0000] Error response from daemon:
Container hb is not running
I also face the same as you to run the couchdb bash command
docker exec -it my-couchdb bash
and
docker exec -it my-couchdb /opt/couchdb/bin/remsh
Error message:
Error response from daemon: Container 54ca56353e3839ff0b824cf5468973aff021d14ad6b2531b85a1b95437b2ae13 is not running
For me the solution was...
I did the all kind of setup whenever I have created the container
Command:
docker run -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password --publish=5984:5984 --name my-couchdb --volume=$HOME/Desktop/BigData/docker-couchdb/data:/opt/couchdb/etc/local.d -d couchdb
If someone face the same problem as mine then try first others solution and if all of the others solution not work then please try once mine, hope it will work finally.

Resources