Logs are not created because there is no container running. build
builds an image and leaves it available, so you can use it to create < in> containers . The application building logs, jetty running in build
and everything else is just the command creating the image, ie, dropping the dependencies (as specified in RUN
of Dockerfile
, etc.) and not necessarily by running the container . Notice that until then we do not have a container , since build
is an image command, not container . See the topics for both.
To execute all the stream you want, let's consider that you have constructed your image as follows (assuming you are in the directory where Dockerfile
is):
docker build -t jetty-log4j .
If the build succeeds, listing the images ( docker images
you will 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 rotate it and for this we have run
". This guy first creates a container and then launches it. It is a combination of create
and start
, just to make our life easier:)
So, to create and start our container we can do the following:
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 point that your log will be created, because now there is actually a container running, so your application is running.
If you want to run create
first and then start
, you can do this:
docker create --name jetty-log4j-test \
-d \
-p 8080:8080 \
jetty-log4j
And then:
docker start jetty-log4j-test
start
can be used from now on, you do not need to use run
again, since you already have the container created, only if you want other container of the same image.
Now we can docker ps
to see if the container is really running 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 in path configured, since now we actually have a container running, not just an image. p>
To stop the container just do this:
docker stop jetty-log4j-test
For other commands, see the documentation available at cli .