Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is Docker-Compose removing one of my containers after its built? #1781

Closed
VinceBarresi opened this issue Jul 28, 2015 · 7 comments
Closed

Comments

@VinceBarresi
Copy link

I have a muti-container web application which I'm linking with Docker-Compose. One of the containers is an ubuntu trusty based image which installs automation tools to headlessly test the front end of the app. For some reason, this container is being killed right after its created. Is this expected? Is there a way I can keep it 'alive'? I apologize before hand if this is something obvious but I haven't found many resources online so I figured I'd ask here.

Console output:

done.
 ---> ecbea2f08b26
Removing intermediate container fe7b632d2926

Here is my docker-compose.yml:


postgres:
  image: postgres:9.3
  environment:
    POSTGRES_USER: ####
    POSTGRES_PASSWORD: ####
    POSTGRES_DB: ####
  volumes:
    - "../db_dump/outfile.sql:/temp/outfile.sql"

csmock:
  build: ../cs_mock
  ports:
    - "8080:8080"

web:
  build: ../web_cda
  links: 
    - csmock
  ports:
    - "8090:8080"
  volumes:
    - "../web_cda/web-server-config.groovy:/usr/local/tomcat/conf/web-server-config.groovy"
    - "../web_cda/env.js:/usr/local/tomcat/conf/web/env.js"

automation:
  build: ../automation
  ports:
    - "4444:4444"
  links:
    - web
@dnephin
Copy link

dnephin commented Jul 29, 2015

That "Removing intermediate" is unrelated to your problem, it's a normal step in the build process.

What command are you running? If you're running docker-compose up without -d and one of your containers exits, you might be hitting #741, which should be fixed in the 1.4 release.

If that's not it, could you provide more context, and maybe a pastebin of the full console log.

@VinceBarresi
Copy link
Author

Hey, thanks for the quick response. So I am running docker-compose up -d from inside a bash script. For some reason, the same container exits right after its built. It doesn't happen to the other 3. As far as issue #741 , It doesn't really sound like its related because I am running with -d flag and only one container exits. Here is the full paste bin log.

http://pastebin.com/fgTiLBf0

Here is the Dockerfile for the container thats being removed:

FROM ubuntu:trusty
RUN apt-get -y update
RUN apt-get install -y -q software-properties-common wget
RUN add-apt-repository -y ppa:chris-lea/node.js
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
RUN apt-get update -y
RUN apt-get install -y -q \
  curl \
  vim \
  google-chrome-beta \
  openjdk-7-jre-headless \
  nodejs \
  x11vnc \
  xvfb 
RUN mkdir /usr/src/tests
COPY /tests /usr/src/tests
RUN npm install -g protractor

@dnephin
Copy link

dnephin commented Jul 29, 2015

docker logs smoke_automation_1 should hopefully have some details about the failure. This does seem like it's the application in the container that is failing which is why it has exited.

@dnephin
Copy link

dnephin commented Jul 29, 2015

Actually, ya. The command it's running is "/bin/bash", and I don't see a CMD in the Dockerfile. That's why it exits right away.

@VinceBarresi
Copy link
Author

Do I need a CMD in the Dockerfile? I'm not sure how the command was set to "/bin/bash" by the way. I just found on stack overflow that I can use CMD["/sbin/init"] if I don't want to run a command. Is this advised? Is there something you'd recommend? I just executed my script again with CMD["/sbin/init"] at the bottom of my Dockerfile and the container was running when I ssh'd into my docker-machine. Its weird though because in the console I see this:

---> c80d535b72a2
Removing intermediate container bec004a3fffb
Step 11 : EXPOSE 4444
 ---> Running in 06947f15be1e
 ---> 8fefbf72c359
Removing intermediate container 06947f15be1e
Step 12 : CMD /sbin/init
 ---> Running in d9979dea9fe7
 ---> 801b5e69238b
Removing intermediate container d9979dea9fe7
Successfully built 801b5e69238b
Creating smoke_automation_1...

Why is it showing that the container is being removed in this context? It wasn't actually removed as far as I could see. Am I missing something?

docker@web:~$ docker ps
CONTAINER ID        IMAGE                     COMMAND                CREATED             STATUS              PORTS                    NAMES
842d618f1833        smoke_automation:latest   "/sbin/init"           7 minutes ago       Up 7 minutes        0.0.0.0:4444->4444/tcp   smoke_automation_1
8a183f0783ec        smoke_web:latest          "catalina.sh run"      12 minutes ago      Up 12 minutes       0.0.0.0:8090->8080/tcp   smoke_web_1
064469f347f1        smoke_csmock:latest       "catalina.sh run"      12 minutes ago      Up 12 minutes       0.0.0.0:8080->8080/tcp   smoke_csmock_1
08dc2a090bfb        postgres:9.3              "/docker-entrypoint.   13 minutes ago      Up 13 minutes       5432/tcp                 smoke_postgres_1

@dnephin
Copy link

dnephin commented Jul 29, 2015

It's not removing your container, it's removing an intermediate that was used as part of the build process. This is expected

@VinceBarresi
Copy link
Author

Ah, ok. My mistake. Thanks for your help. It seems to be staying up now.

@dnephin dnephin closed this as completed Aug 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants