Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any quick ways to reset the change in docker container?

Tags:

docker

I could use docker diff to inspect changes to files or directories on a container's filesystem, like next:

$ docker diff inventory_web
C /var
C /var/cache
C /var/cache/nginx
A /var/cache/nginx/uwsgi_temp
A /var/cache/nginx/client_temp
A /var/cache/nginx/fastcgi_temp
A /var/cache/nginx/proxy_temp
A /var/cache/nginx/scgi_temp
C /run
A /run/nginx.pid
C /etc
C /etc/nginx
C /etc/nginx/conf.d
C /etc/nginx/conf.d/default.conf

But I wonder if any quick ways I could use to reset the /etc/nginx/conf.d/default.conf to the default contents of the image which this container used?

Something like the operation in git: git checkout -- default.conf, could we use something like docker reset or docker checkout etc.?

Currently, I had to start a new container based on the same image, and copy the files in that container to my old container. But I think docker overlay file system certainly know what changed in the rw layer compared to the ro layer in image as it's layer based, otherwise, how docker diff could work?

like image 340
atline Avatar asked Dec 28 '25 19:12

atline


1 Answers

Docker isn't SCM but you can use kinda a hack to copy the file from your base image.

docker cp $(docker create --rm <container_image>):/etc/nginx/conf.d/default.conf default.conf
docker cp default.conf <running_container_id>:/etc/nginx/conf.d/default.conf 
like image 195
Andrei Kovrov Avatar answered Dec 30 '25 16:12

Andrei Kovrov