Docker Commands
Resources
Basic Commands
start a container:
docker start kafka
follow log of a container:
docker logs -f kafka
SSH into a Container: https://phase2.github.io/devtools/common-tasks/ssh-into-a-container/
docker exec -it zookeeper /bin/sh
docker image inspect mongo
docker run -d centos tail -f /dev/null
==> avoid the centos container to terminatedocker run --entrypoint "/bin/ls" debian -al /root
==> override entrypointdocker run -it --entrypoint "/bin/bash" 16ae4fa4bfe5 -i
==> override entrypoint and keep container runningdocker run --rm -p 8080:8080 base-image
==> run and image and automatically remove remove the container when it exits
Docker Compose Commands
Basic docker commands: https://phoenixnap.com/kb/how-to-list-start-stop-docker-containers
start all docker compose:
docker-compose up -d --build
stop all docker compose:
docker-compose stop
remove all docker compose:
docker-compose rm -f
After starting docker composer you should be able to access Confluent Console at http://localhost:9021/clusters
enter docker compose containers:
docker-compose exec broker bash
docker-compose exec ksql-cli ksql
http://ksqldb-server:8088
Ho to build a docker file
From the directory of the Dockerfile run:
docker build [-t <tag name>] [--no-cache] .
Docker house keeping
Cleaning up containers
docker kill $(docker ps -q)
==> Kill all running docker containerdocker rm $(docker ps -a -q)
==> delete all stopped docker containersClean up images
docker rmi <image name> .
docker rmi $(docker images -q -f dangling=true) .
==> remove untagged (dangling) images (-q
is the quite option (gives a list of container_ids only) and-f
if the filter option)docker rmi $(docker images -q) .
==> delete all imagesCleaning up volumes
docker volumes rm $(docker volume ls -f dangling=true -q)
==> remove all the dangling volumes
Docker push
(resources: https://ropenscilabs.github.io/r-docker-tutorial/04-Dockerhub.html)
Inspect
inspect ARG values after an image is built
docker history
inspect the default ENV variable values before the container is started:
$ docker images $ docker inspect <image-id>
Last updated