Docker adalah aplikasi yang memudahkan proses pengelolaan proses aplikasi dalam containers. Containers memungkinkan Anda menjalankan aplikasi dalam proses dan sumber daya yang terisolasi. Mereka mirip dengan mesin virtual, tetapi kontainer lebih portabel, lebih ramah sumber daya, dan lebih bergantung pada sistem operasi host.
Installing Docker #
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
Tunggu proses instalasi selesai
# sh get-docker.sh
# Executing docker install script, commit: e5543d473431b782227f8908005543bb4389b8de
+ sh -c 'yum install -y -q yum-utils'
+ sh -c 'yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo'
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
+ '[' stable '!=' stable ']'
+ sh -c 'yum makecache'
Metadata cache created.
+ sh -c 'yum install -y -q docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin'
+ sh -c 'docker version'
Using the Docker Command #
Add user into docker group #
groupadd docker
sudo usermod -aG docker $USER
sudo chmod 666 /var/run/docker.sock
Running docker #
docker run hello-world
Output
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:6a65f928fb91fcfbc963f7aa6d57c8eeb426ad9a20c7ee045538ef34847f44f1
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
Search images #
docker search nginx
Download image #
docker pull nginx
Show images #
docker images
Running container #
docker run -it ubuntu
List containers #
docker ps -a
Manage containers #
docker start 0596bd489a2d
stop, start, restart
Inspect containers #
docker inspect 0596bd489a2d
Untuk mengambil informasi tertentu di containers.
docker inspect -f '{{.Name}} - {{.NetworkSettings.IPAddress }}' $(docker ps -aq)