Docker Installation On Centos 7



Docker installation on CentOS 7 is a bit easier than installing on Ubuntu. If you followed this guide, you should have successfully installed Docker on your CentOS 7 machine. Now you can explore the wonderful world of Docker. On desktop systems like Docker Desktop for Mac and Windows, Docker Compose is included as part of those desktop installs. On Linux systems, first install the Docker Engine for your OS as described on the Get Docker page, then come back here for instructions on installing Compose on Linux systems.

You can change Docker’s storage base directory (where container and images go) using the -g option when starting the Docker daemon.

  • Ubuntu/Debian: edit your /etc/default/docker file with the -g option: DOCKER_OPTS='-dns 8.8.8.8 -dns 8.8.4.4 -g /mnt'

  • Fedora/Centos: edit /etc/sysconfig/docker, and add the -g option in the other_args variable: ex. other_args='-g /var/lib/testdir'. If there’s more than one option, make sure you enclose them in ' '. Docker ping. After a restart, (service docker restart) Docker should use the new directory.

Using a symlink is another method to change image storage.

Install Docker On Centos 7 Vm

Docker installation on centos 7 command

Caution - These steps depend on your current /var/lib/docker being an actual directory (not a symlink to another location).

Docker Installation On Centos 7 32-bit

  1. Stop docker: service docker stop. Verify no docker process is running ps faux
  2. Double check docker really isn’t running. Take a look at the current docker directory: ls /var/lib/docker/
    2b) Make a backup - tar -zcC /var/lib docker > /mnt/pd0/var_lib_docker-backup-$(date +%s).tar.gz
  3. Move the /var/lib/docker directory to your new partition: mv /var/lib/docker /mnt/pd0/docker
  4. Make a symlink: ln -s /mnt/pd0/docker /var/lib/docker
  5. Take a peek at the directory structure to make sure it looks like it did before the mv: ls /var/lib/docker/ (note the trailing slash to resolve the symlink)
  6. Start docker back up service docker start
  7. restart your containers