Docker installation for centos

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io
systemctl start docker
docker run hello-world
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

See active containers

docker ps -a
docker container ps --all

Docker file example

FROM httpd:2.4
COPY ./public-html/ /usr/local/apache2/htdocs/

Build using bocker file in the same dir

docker build -t my-apache2 . 

See all docker images

docker images

Delete an image

docker rmi <id>

Stop a container

docker stop <id>

Enter in a container and start a /bin/bash session

docker exec -it <id> /bin/bash

Copy file

# from host to container
docker cp <source> <container_id>:<destination>
# from container to host
docker cp <container_id>:<source> <destination>

Docker compose up and build

docker-compose up --build -d

Prune images and containers

docker system prune
docker system prune -a

Docker service

# create a service
docker service create --publish 3003:3003 --name jw-ms --network intranet-dev-1 jw-ms
# force update a service
docker service update --force jw-ms

Categories: Server

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.