INFO CENTRAL HOME

Info Center has pages, examples, hints, and snippets on the various topics in the menu above. Explore and enjoy.

Docker Container Information


Copied the contents of container "25b2a57382cd:/deepdream" to "/media/jack/HDD\ 500/DESKTOP2/Desktop/DEEPDREAM/deepdreamcontainer"
docker cp -a 25b2a57382cd:/deepdream /media/jack/HDD\ 500/DESKTOP2/Desktop/DEEPDREAM/deepdreamcontainer
docker cp -a dreamer:/deepdream /home/jack/Desktop/DOCKER/deepdream/deepdreamcontainer

Copy a local file into container
docker cp ./some_file CONTAINER:/work
docker cp /home/jack/Pictures/720-square-costume.jpg dreamer:/deepdream/deepdream

Copy files from container to local path
docker cp CONTAINER:/var/logs/ /tmp/app_logs

Copy a file from container to stdout. Please note cp command produces a tar stream
docker cp CONTAINER:/var/logs/app.log - | tar x -O | grep "ERROR"


sudo systemctl stop docker
sudo systemctl stop docker.socket
sudo systemctl stop containerd
sudo nano /etc/docker/daemon.json
sudo rm /var/lib/docker
sudo systemctl start docker
docker info -f '{{ .DockerRootDir}}'
docker images


---------- /etc/docker/daemon.json ---------------------
{
  "debug": true,
  "data-root": "/media/jack/HDD5001/docker"
}






------------------------------
TD;DR -- worked on Ubuntu 18.04 just before post
follow the instructions:

sudo systemctl stop docker
sudo rsync -axPS /var/lib/docker/ /mnt/x/y/docker_data #copy all existing data to new location
sudo vi /lib/systemd/system/docker.service # or your favorite text editor
in file docker.service find one line like this:

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

add --data-root /mnt/x/y/docker_data to it(on one line):

ExecStart=/usr/bin/dockerd --data-root /mnt/x/y/docker_data -H fd:// --containerd=/run/containerd/containerd.sock

save and quit, then

sudo systemctl daemon-reload
sudo systemctl start docker
docker info | grep "Root Dir




How to move the default /var/lib/docker to another directory for Docker on Linux?
Posted February 9, 2021
Linux BasicsLinux CommandsDockerUbuntuDebianCentOSI recently had a case where the / partition was running very low on disk space, but I also
had an additional disk mounted at /home/ with plenty of disk space.
However as by default Docker stores everything at /var/lib/docker my / partition was nearly full.
To fix that I moved the default /var/lib/docker to another directory on the /home partition.

Before you get started, make sure to backup your Droplet so that in case that anything goes wrong, you could revert back to a backup!
Once you have your backup in place, follow these steps here:
SSH to your server
Make sure that Docker is stopped:
sudo systemctl stop docker
After that, make sure that Docker is not running with the following commands:
sudo systemctl status docker
If you see that Docker is not running, then you could proceed. Another way of checking if there are any Docker processes is by using the ps command:
ps faux | grep -i docker
After that, copy the /var/lib/docker/ Docker directory to the new location. Let’s say that we want to put the files in a folder called /home/docker. To do so, first create the folder:
mkdir /home/docker
Then using the rsync command transfer the files over:
rsync -avxP /var/lib/docker/ /home/docker
Note: this might take a while depending on the size of your images. If your folder is too large you might want to run the rsync command in a screen session to avoid your connection being dropped and interrupting the transfer.
Next, you need to update the Docker unit file. To do that, using your favorite text editor, edit the following file:
sudo nano /lib/systemd/system/docker.service
Find the following line:
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
And change it to:
ExecStart=/usr/bin/dockerd -g /home/docker -H fd:// --containerd=/run/containerd/containerd.sock
Then reload the systemd daemons:
sudo systemctl daemon-reload And finally, start Docker:
systemctl start docker Finally, to confirm if your images are being loaded from the new path, you can inspect one of your images: Find an image id: docker images Inspect the image and look for the WorkDir: docker inspect image_id | grep WorkDir I hope that this helps! Regards, Bobby Reply mwrochna • September 6, 2021 Stop the server: sudo systemctl stop docker Create/edit the configuration at /etc/docker/daemon.json, for example: { "data-root": "/new/path/docker-data-root" } Copy your data there: sudo cp -axT /var/lib/docker /new/path/docker-data-root (if the target docker-data-root directory already exists, make sure you don’t accidentally copy into a docker subdirectory). Start the server: sudo systemctl start docker Check everything works: sudo docker images The previous answer: Uses an obsolete/undocumented(?) option -g. Instead you should use the option documented in dockerd --help, which is --data-root. Edits the service file, which might cause problems when installing updates. Instead you should edit /etc/docker/daemon.json. Uses rsync to copy files without preserving ACLs, xattrs and hard links, though I’m not sure there’s any