Itai Ganot
Itai Ganot

Reputation: 6305

After docker build . the container is not displayed, why?

I'm trying to build a docker container with log.io. If I manually run:

docker run -it node:argon -p 28777:28777 -p 28778:28778 -p 8000:80 /bin/bash

and manually run inside the command which you see in the Dockerfile then everything works perfectly and I am able to log into the service using http.

FROM node:argon

WORKDIR Logz.io/src/

RUN useradd -ms /bin/bash ubuntu

#RUN mkdir /root/.log.io \
#       && touch /root/.log.io/harvester.conf \
#       && touch /root/.log.io/log_server.conf \
#       && touch /root/.log.io/web_server.conf

#RUN chmod g+rwx /root/logzio
RUN apt-get update \
        && apt-get install -y vim net-tools

RUN npm install log.io

RUN /node_modules/log.io/bin/log.io-server &

RUN /node_modules/log.io/bin/log.io-harvester &

EXPOSE 28777
EXPOSE 28778
EXPOSE 8000

But if I run:

docker build .

The container is created, everything is installed but:

  1. When the creation finishes and I run docker ps -a, the container is not displayed (even though I get it's details when I run docker inspect).
  2. The Log.io service is unavailable when I browse to it through http.

Anyone knows what I'm doing wrong?

Upvotes: 14

Views: 24367

Answers (2)

Scot Matson
Scot Matson

Reputation: 745

When you finish building an image from a Dockerfile, a container will not be readily available. You will need to create a container from the image that was created

You can see your images with the command docker images

From this list of images, you can create your container via docker run ...

If your docker container is not visible after running it, something is likely failing in your build and that would stem from your Dockerfile.

Upvotes: 1

Dockstar
Dockstar

Reputation: 1028

Docker build does not create a container, it creates an image.

If you do:

docker build -t "myimage:0.1" .

Then do

docker run -it myimage:0.1 -p 28777:28777 -p 28778:28778 -p 8000:80 /bin/bash

it will instantiate a container based on the image you just built.

Upvotes: 27

Related Questions