Docker Commands
Resources
Basic Commands
start a container:
docker start kafkafollow log of a container:
docker logs -f kafkaSSH into a Container: https://phase2.github.io/devtools/common-tasks/ssh-into-a-container/
docker exec -it zookeeper /bin/sh
docker image inspect mongodocker 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 --buildstop all docker compose:
docker-compose stopremove 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 bashdocker-compose exec ksql-cli ksqlhttp://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 (-qis the quite option (gives a list of container_ids only) and-fif 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)
docker login --username=yourhubusername
docker images
docker tag bb38976d03cf [yourhubusername]/[repo_name]:[tag]
docker push [yourhubusername]/[repo_name]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
Was this helpful?