Logs are not created because there is no container spinning. build
build an image and make it available, so you can use it to create containers. The application construction logs, the Jetty running on the build
and everything else is just the command creating the image, ie downloading the dependencies (as specified in RUN
of Dockerfile
, etc.) and not necessarily running the container. Note that until then we do not have one container, since build
is an image command, not container. See us topics what is of one and another.
To run the entire stream you want, let’s consider that you have built your image as follows (assuming you are in the directory in which the Dockerfile
):
docker build -t jetty-log4j .
If the construction is carried out successfully, by listing the images (docker images
you’ll have something like this:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jetty-log4j <none> 81a458346fd6 5 minutes ago 605 MB
Created the image now we have to create a container and spin it and for this we have the run
. This guy first creates a container and then starts it. It is the combination of create
and start
, just to make our lives easier :)
So, to create and start our container we can do it this way:
docker run --name jetty-log4j-test \
-d \
-p 8080:8080 \
jetty-log4j
This will create a container called jetty-log4j
and run it. It is at this time that your log will be created, as there is now in fact a container running, so your application is running.
If you want to execute the create
and then the start
, can do so:
docker create --name jetty-log4j-test \
-d \
-p 8080:8080 \
jetty-log4j
And then:
docker start jetty-log4j-test
The start
can be used from now on, no need to use the run
again, since you already have the container created, only if you want another container of the same image.
Now we can do the docker ps
to see if the container it’s really spinning and we’ll have something like this:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9c01fb0b739a jetty-log4j bash 17 seconds ago Up 16 seconds 8080/tcp jetty-log4j-test
It is after this step that we can notice the log on path configured, since it is now that we actually have a container running, not just an image.
To stop the container just do this:
docker stop jetty-log4j-test
For other commands, see in the documentation everything available on cli.
docker build
just create the image, are you creating/running a container? For example, if you make adocker ps
, Can you see if there’s a container running? If not, do something likedocker run <parametros> <nome-da-sua-imagem>
to start a new container, if you already have one created, dodocker start <nome-container>
– Bruno César