Home > Article > Operation and Maintenance > Where are the internal files of the docker container?
Docker container files are stored in the container file system isolated from the host file system, the specific locations are /var/lib/docker/containers/
/ / and / var/lib/docker/overlay2/ /merged/. Container files can be accessed through the Docker exec, Docker cp, and Docker inspect commands.
The storage location of files within the Docker container
Docker containers use an isolated sandbox environment in which files and directories are stored in the container's file system. This file system is different from the host's file system and is created when the container starts.
Container file system
Container file system usually uses a layered file system (such as AUFS or overlayfs), which combines the file system of the base image with the container-specific Change the layered overlay. This allows containers to modify files without affecting the underlying image, and simplifies container updates and cleanups.
Container file location
By default, container files are stored in the following location:
/var/lib/docker /containers/<container-id>/<layer-id>/
: Contains the files and directories of the container layer. /var/lib/docker/overlay2/<container-id>/merged/
: Contains the container's merged file system, including the base image and container changes. Accessing container files
There are several ways to access container files:
docker exec
command to execute commands in the container and access the container's file system. docker cp
command to copy files from the container to the host, or from the host to the container. docker inspect
command to obtain the file system details of a container. It should be noted that the container file system is ephemeral. Once a container is stopped or deleted, its file system will also be deleted. Therefore, make sure to back up your container files when needed.
The above is the detailed content of Where are the internal files of the docker container?. For more information, please follow other related articles on the PHP Chinese website!