Reputation: 57949
I am a newbie to Docker and I am trying to see if I can get logs for the following instructions when they are getting executed.
FROM ubuntu:16.04
ENV name John
ENTRYPOINT echo "Hello, $name"
My aim here is check how(the path etc.) the shell mode is working in executing the ENV
here and also how the ENTRYPOINT is being executed.
I can imagine these kind of logs could be useful in debugging purposes, so probably I am missing something obvious. Any ideas please?
Upvotes: 0
Views: 438
Reputation: 158724
The Dockerfile instructions don’t do much; they record some state in fields in the built Docker image. As @BrayanCaldera’s answer indicates, you’ll see these go by in the docker build
output, but nothing runs during container build time.
If the ENTRYPOINT is a full-blown script then you can use usual script debugging techniques on it to see what happens when the container starts up. For instance:
#!/bin/sh
# Print out every command as it executes
set -x
# Print out the current environment
env
# Run the actual command
exec "$@"
To tell the Docker image what to do by default when you docker run
you should usually use the CMD directive. If you need to do pre-launch setup then an ENTRYPOINT script that uses exec "$@"
to run the CMD is a typical path.
Upvotes: 2
Reputation: 2199
For see the logs on terminal you only need to execute this line:
docker build --rm -f dockerfile -t log:latest .
If you need to store these logs in a file you only need to execute this line:
docker build -t logs . > image.log
Upvotes: 0