1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
//when you get your vm with centos8 //download the source dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo //install it dnf install docker-ce docker-ce-cli containerd.io //Start the Docker service and add it to autorun. systemctl enable --now docker //install firewall for detail: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-firewalld-on-centos-8 sudo dnf install firewalld sudo systemctl enable firewalld sudo systemctl start firewalld sudo firewall-cmd --state #running //CentOS 8 uses a firewall other than Docker. Hence, if you have firewalld enabled, you need to add a masquerade rule to it. firewall-cmd --zone=public --add-masquerade --permanent firewall-cmd --reload //install docker compose curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose //Make it executable. chmod +x /usr/local/bin/docker-compose //put it to bin cp /usr/local/bin/docker-compose /bin/docker-compose //To be able to use Docker as a non-root user, you must add that user to the docker group. usermod -aG docker [username] //restart docker one more time for firewall update service docker restart //run your docker //done //start up docker task docker-compose up -d //start up but can see all script & error docker-compose up //list docker item docker ps //list all docker item even closed docker ps //exec in some docker item docker-compose exec [docker-item-name] nginx -t docker-compose exec [docker-item-name] php artisan key:generate //restart one container only with docker-compose docker-compose restart [docker-item-name] //restart one container only with docker-compose (set the time to wait for stop before killing the container (in seconds) docker-compose restart -t 30 [docker-item-name] //go inside to docker item docker exec -it [docker-item-name] bash //go inside to docker item as root //for php docker exec -u 0 -it [docker-item-name] bash //for restart php-fpm kill -USR2 1 //for nginx docker exec -it [docker-item-name] /bin/sh //stop all docker task docker-compose down //stop all docker task also remove the image docker-compose down --rmi all //check processing port in server sudo netstat -tulpn | grep LISTEN sudo ss -tulpn | grep LISTEN //list installed images docker images //remove image docker image rm [id] //remove all image docker image prune -a //list installed containers docker ps //remove container docker rm [id] |