Contoh Perintah Docker

Melihat list container yang aktif

docker ps

Melihat semua list container

docker ps -a

Me-list semua images

docker images

Build docker image from Dockerfile

docker build -t <tag-name> <Dockerfile-dir>

Run docker container sekali jalan

docker run <images-name>

Run docker container secara interactive (misal untuk menjalankan bash)

docker run -it <images-name> <runnable-apps>
docker run -it ubuntu bash

Run docker container secara daemonized

docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"

Melihat logs docker yang berjalan secara daemonized

docker logs [-f] <container-id>


docker logs [-f] <ports-name>

Run docker container

docker run <image name> <executable file> <param of executable file>
docker run ubuntu echo aaaaa

Run docker container dengan random port mapping

docker run -d -P training/webapp python

Run docker container dengan defined port mapping

docker run -d -p 80:5000 training/webapp python

Masuk ke container shell

docker exec -it <ports-name> /bin/bash

Keluar dari shell tanpa memberhentikan container

ctrl+p, kemudian ctrl+q

Stop docker container

docker stop <container-id>


docker stops <ports-name>

Remove docker images

docker rmi <image-tag>

Remove docker container

docker rm <container-id>


docker rm <ports-name>

Stop all container

docker stop $(docker ps -a -q)

Remove all container

docker rm $(docker ps -a -q)

Remove all images

docker rmi $(docker images -q)





Leave a Reply

Your email address will not be published. Required fields are marked *