Reputation: 2806
Is there a convenient way to find out all installations and changes made inside a docker container after the container was built? Because its not recommended to commit the changes to a new image, how could I easily find out all changes so that I can put them in the Dockerfile?
Upvotes: 2
Views: 1024
Reputation: 644
There are different ways to get helpful information.
To get logs of a container, use docker logs command, the syntax is:
# docker logs [OPTIONS] CONTAINER
For a full list of available options, run:
# docker logs --help
You can also pipe the output of the command to tools like grep
to filter output. See example below.
# docker run -it --rm --name test ubuntu:16.04 /bin/bash
root@fde8369a7439:/# apt-get update
root@fde8369a7439:/# apt-get install nginx
root@fde8369a7439:/# apt-get install vim
Now check the logs, grep for apt-get
.
# docker logs test | grep apt-get
If you want to save the logs to a file on docker host machine, use:
# docker logs test > test_logs
You can also utilize bash history of a container to pull some info on what you did:
# docker exec container cat /root/.bash_history
The docker diff
command is often used to inspect changes to files or directories on a container's filesystem. It doesn’t give you exact commands you execute but modified files.
Upvotes: 2
Reputation: 7793
docker container diff
is what you need: https://docs.docker.com/engine/reference/commandline/container_diff/
Upvotes: 0