Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

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?

like image 608
Itai Ganot Avatar asked Dec 06 '16 18:12

Itai Ganot


2 Answers

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.

like image 111
Dockstar Avatar answered Nov 15 '22 15:11

Dockstar


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.

like image 26
Scot Matson Avatar answered Nov 15 '22 14:11

Scot Matson