I used to inspect docker's container file using docker inspect -f '{{.Id}}' container_id, then the container's files are located in /var/lib/docker/aufs/mnt/{container_full_id}(I didn't change the default configuration, so it's the default location), the version of docker is 1.6.1 at that time.
But now, I'm running docker 1.10.3, I used the same command docker inspect -f '{{.Id}}' container_id, but I can't find the folder in the location that it used to be, nor in /var/lib/docker/aufs/diffs/{container_full_id}.
Is it docker modify its folder structure, or is there anything wrong with my commands?
Any help will be appreciated. Thanks.
by writing "docker inspect containername" You should get full JSON info about container. There is some info about the paths like ResolvConfPath (so the location of the container files as well)
docker-layer provide an easy way to find a container's filesystem root mount :
# docker-layer -m musing_wiles
/var/lib/docker/aufs/mnt/c83338693ff190945b2374dea210974b7213bc0916163cc30e16f6ccf1e4b03f
Edit 2018-03-28 :
docker-layer has been replaced by docker-backup
Related
I have a docker image, and I am running it now (finishing with bash)
When I do, I have a file structure inside the container.
However, this is not some file structure mapped (with -v) from outside the container. These files and folders exist only inside the container.
My question is, since it is bothersome to be opening each file with vi and navigating from the terminal, is there a way that I can open vscode on these files?
Be aware that these files do not exist outside the container
I found how to do it from this link
However I used the "attach to running container" command
I rarely do that but when I have to I usually mount an empty volume to the container, then exec into the container copy the folder which I need into that empty volume, which is then replicated on my host machine. From my host machine I then open it in vscode.
However please be careful if you have sensitive information in that container, not to expose something by accident.
So the steps are:
Create empty volume ( docker-compose example )
Note do not overwrite the folder/file which you want to extract. containerpath is path which does not exist in the container prior to creating it.
volume:
- ./hostpath:/containerpath
Find docker id so that you can use it to exec into it:
docker ps
Exec into the container:
docker exec -it <container_id> /bin/sh
Copy the file/folder to that empty volume:
cp -r folder containerpath
Exit the container and look at your files in ./hostpath folder.
Similar question: mac image path
In mac, when I run docker inspect containerID
I see most of the stuff is coming from /var/lib/docker/
however, this path neither exists in the host (mac) nor the docker container.
where is this path refer to?
you can find your files in container:path and use the docker commands to copy them to your local machine and vice versa (I'm assuming you are trying to move files e.g. from your local machine to your container). I had the same exact issue you mentioned but I manage to move files with
docker cp local_path containerID:target_path
to see your container_ID simply run docker ps -a, it should show it even if unmounted.
See https://docs.docker.com/engine/reference/commandline/cp/
I downloaded the official node-red container.
I noticed that the file 'setting.js' is missing inside it.
I tried to insert it manually inside the container but it is not read when node-red is started. I was wondering if there was a way to insert it or anyway an alternative way to set the credentials to access the admin page of node-red.
I pull nodered/node-red-docker:0.18.4-v8.
Usually setting.js file is inside .node-red/setting.js, but not in this case. This container have the path: /usr/src/node-red/ and when I enter with command docker exec -it container_name bash, i'm inside the directory node-red. I tried to put the setting.js in this path but not work
You should not change the copy of settings.js in /usr/src/node-red this is the default and should be left alone. Also editing this file after starting the container will not work as it is copied to the userDir the first time Node-RED is started.
If you want to include your own version you should mount it into the /data directory as this is the userDir for the system when running.
You can use the docker -v option to mount a local copy of the file into the container.
docker -v /path/to/settings.js:/data/settings.js ...
I created own Dockerfile, during building I inserted to /opt/wilfly/log my log4j.xml.
Now I need create volume /mnt/data/logs/application:/opt/wildfly/log
I run command
sudo docker run --name=myapp -v /mnt/data/logs/application:/opt/wildfly/log -d -i -t application
But when I look in docker container, folder /opt/wilfly/log is empty. In this folder should by log4j.xml.
Thank you.
Maybe you should move it into another directory.
For example move log4j.xml to /opt/wilfly/ and set logging path to /opt/wilfly/log.
When you run the container, log4j.xml will not disappear.
When you mount the data, the folder from your host "override" your mounted folder within the container.
Thus, there are some options you can do:
copy the log4j.xml into your local /mnt/data/logs/application folder and run the container as you did.
remove the -v /mnt/data/logs/application:/opt/wildfly/log and use the original log4j.xml that you were added during the image build.
Please note that you can also mount only the file if you like (rather than the entire floder): -v /mnt/data/logs/application/log4j.xml:/opt/wildfly/log/log4j.xml but it won't change the behavior - the file from your host will be mounted into the container and not in the opposite direction.
I am trying to copy file from docker container to host. I have attached the snapshot in which I listed all the containers as well as container file structure. But when I execute docker cp, it says it could not find the file. Can anyone tell me what wrong am I doing or if I am missing something. I am very new to docker so please guide me through.
I think you need to absolute path to the file inside the container. See the following.
Copying files from Docker container to host
docker cp <CONTAINER>:/<ABS_PATH>/procfile .
As documented for the docker cp command:
The docker cp command assumes container paths are relative to the
container’s / (root) directory
Thus CONTAINER:file.txt is equivalent to CONTAINER:/file.txt as paths are interpreted relative to the root /