Docker Community Forums

Share and learn in the Docker community.

Where are the image error log - my second container doesn't start

build

(Ben Zhou) #1

Hello,

it seems it is impossible to start multiple containers from the same image. So I committed the same container to multiple images using different tags and tried to run them individually to achieve the same result.

The docker run command seems to complete successfully, outputting a long container id. But a docker ps shows nothing running from the second image. Since the container didn’t run, ‘docker logs’ provides no result.

I suspect it is because of my system resource is too low. The environment on which i’m doing this is a Lenovo T60P laptop with just 3GB memory, with Ubuntu 14.04.

The image I’m working on is quite large, 804MB.

Where can I find out why it doesn’t start properly?


(Michael Clifford) #2

What do you mean by this?


(Ben Zhou) #3

Hi Mike,

thanks for responding to my newbie question nontheless. it seems I have to take the original statement back.
my newly built image uses one port, typically 1414, 1415, … So I have to map host port to the container port, whatever it is. The image I built is bfzhou/ubuntumq:1.0

It seems the following command with the option -d works only once:
docker run -d -p 14414:1414 bfzhou/ubuntumq:1.0
the second time I run against the image with the command
docker run -d -p 14415:1415 bfzhou/ubuntumq:1.0
the command spits out a long id, but ‘docker ps’ shows only the first one running.
it starts only if I replace the ‘-d’ option with ‘-ti’. of course I end up in a command prompt of the started container.

I must have missed something? would you mind pointing out what it is that prevents the one with ‘-d’ option to succeed?

thanks so much,
Ben


(Michael Clifford) #4

Do you have this image pushed to Docker hub or the Dockerfile published somewhere? Everything you’ve posted looks fine and I can’t see any reason why the 2nd docker run would silently exit out unless there was something preventing it from binding on port 1415 internally or 14415 externally.

Are you able to stop and rm all containers and verify they both independently run on each port?

docker run -d -p 14414:1414 --name test bfzhou/ubuntumq:1.0
docker ps
docker stop test
docker rm test
docker run -d -p 14415:1415 --name test bfzhou/ubuntumq:1.0
docker ps docker stop test
docker rm test

(Ben Zhou) #5

I can’t push it to the hub as public image due to license concern - don’t want to get into trouble.

I stopped and removed all container. then run your suggested commands. here’s the result. the container was created but didn’t start.

zhoub@erdbeer:~$ docker run -d -p 14414:1414 --name test bfzhou/ubuntumq:1.0
81c1d61c03ff6e5dd906879b3e5f9d49fddc98ba33f264162d6f7162cd981817
zhoub@erdbeer:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
zhoub@erdbeer:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
81c1d61c03ff bfzhou/ubuntumq:1.0 “/bin/bash” 16 seconds ago Exited (0) 15 seconds ago test

It exits right away! But it starts if I run it with -t option, then Ctrl-C to quit the shell.
zhoub@erdbeer:~$ docker rm docker ps -a | grep -v CONTAINER | awk '{print $1}'
81c1d61c03ff
zhoub@erdbeer:~$ docker run -t -p 14414:1414 --name test bfzhou/ubuntumq:1.0
root@ea19c4562caf:/# ^Czhoub@erdbeer:~$
zhoub@erdbeer:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ea19c4562caf bfzhou/ubuntumq:1.0 “/bin/bash” 9 seconds ago Up 8 seconds 0.0.0.0:14414->1414/tcp test

I noticed if I keep using -t option, I could get as many as 4 containers running in parallel, mapped 1414 to different port in the host, just not with the -d option.

But after the magic 4, no matter what option I use, it just spits out a long containerID, no error message, nothing, just doesn’t run.

thanks so much.
Ben


(Ben Zhou) #6

unbelievable. now I have 7 containers from the same image running. for no apparently reason, the limit experienced before suddenly seems to be gone - on an old laptop with only 3GB ram. the image is 804 MB big. I don’t know how to describe my disbelief !

zhoub@erdbeer:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e792b998a3d5 bfzhou/ubuntumq:1.0 “/bin/bash” 30 seconds ago Up 29 seconds 0.0.0.0:14420->1414/tcp lonely_kare
4d83413b15e0 bfzhou/ubuntumq:1.0 “/bin/bash” 2 minutes ago Up 2 minutes 0.0.0.0:14419->1414/tcp hopeful_pare
730f36143f38 bfzhou/ubuntumq:1.0 “/bin/bash” 2 minutes ago Up 2 minutes 0.0.0.0:14418->1414/tcp tender_bartik
9ca56247e919 bfzhou/ubuntumq:1.0 “/bin/bash” 3 minutes ago Up 3 minutes 0.0.0.0:14417->1414/tcp reverent_liskov
2635b754271a bfzhou/ubuntumq:1.0 “/bin/bash” 4 minutes ago Up 4 minutes 0.0.0.0:14416->1414/tcp silly_heisenberg
e5c1d2aca8bb bfzhou/ubuntumq:1.0 “/bin/bash” 4 minutes ago Up 4 minutes 0.0.0.0:14415->1414/tcp sleepy_euler
ea19c4562caf bfzhou/ubuntumq:1.0 “/bin/bash” About an hour ago Up About an hour 0.0.0.0:14414->1414/tcp test


(Michael Clifford) #7

It appears your images are set to run /bin/bash as the default command. Without the -t option, there is no tty to assign and the container silently fails.

You can reproduce with a container run from an Alpine image:

docker run --rm alpine sh
# the container just exits, docker ps -a shows nothing

docker run --rm -t alpine sh
# the container runs and you have a non-interactive terminal (since we omitted -i)
# if you ctrl-c at this point, `docker ps` shows a running container

If your entrypoint command is going to be a terminal, your container will require a pseudo-tty allocated to it.


(Ben Zhou) #8

thanks for pointing this out.

The base image is ubuntu:14.04, is that set to run /bin/bash? But why the first one starts with the -d option but not after that?