Docker Engine, Compose and Portainer installation on ubuntu 22. Optional: how to change default docker root folder (where images and containers are stored)
tutorial video tested it works To install on Ubuntu 22 you should type these commands in your CLI
$ curl -fsSl https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
$ sudo groupadd docker
$ sudo usermod -aG docker ${USER}
where ${USER} is a variable provided by UNIX-like operating systems that contains the name of the current user, this allows the current user's name to be automatically inserted into the command so that we can add it to the "docker" group.- logout from system then log in back
$ sudo curl -SL https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ docker run -d -p 8005:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest --http-enabled
Also check Dockage as a simple and powerful alternative of Portainer
$ mkdir WHEN_YOU_WANT_NEW_ROOT
$ sudo nano /etc/docker/daemon.json
inside
{
"data-root": "/WHEN_YOU_WANT_NEW_ROOT"
}
$ sudo systemctl restart docker
$ docker info -f '{{ .DockerRootDir}}'
docker cp storage/database.sql trc_for_prod-mysql-trc-1:/tmp/database.sql
copy from local comp to docker container
volumes:
- /var/www/html/node_modules
- /var/www/html/public/fonts
These volumes prevent certain directories from being overwritten when using Docker bind mounts (-v). Here’s why:
1️⃣ /var/www/html/node_modules If you are using Node.js inside the container, the node_modules folder is generated inside the container during npm install. When mounting your local Laravel project (/var/www/html), Docker replaces the container’s directory with your local code. This means that if node_modules is not in a volume, it would get overwritten or deleted when mounting your local project. The volume ensures node_modules remains inside the container and is not affected by the local file system.