Docker Tutorial
Basics ¶
- Docker Hub : Docker Hub is the world's easiest way to create, manage, and deliver your team's container applications.
- CONTAINER is a running environment of an IMAGE
Basic Commands ¶
-
Pull images
docker pull ubuntu:20.04
docker pull [RegistryDomain]/[IMAGENAME]:[TAG]
-
List images
docker images
-
Run container
docker run -p[HOST PORT]:[CONTAINER PORT] -d --name [DOCKER NAME] --net [NETWORK NAME] -e [ENVIRONMENT_VARIABLE_NAME=VALUE] -v [HOST_DIR]:[CONTAINER_DIR] [IMAGE ID]
-
Create a docker network
docker network create [NETWORK NAME]
docker network ls
-
List container process
docker ps -a
-
Start/stop/Remove container
docker start/stop/rm [CONTAINER ID]
-
Logs
docker logs [CONTAINER ID]
-
Execute docker
docker exec -it [CONTAINER ID] /bin/bash
docker exec -it [CONTAINER ID] /bin/sh
-
Tag
docker tag [IMAGE]:[TAG] [RegistryDomain]/[IMAGENAME]:[TAG]
Docker Compose ¶
-
Start all containers
docker-compose -d -f [COMPOSE FILE NAME] up
-
Stop all containers
docker-compose -f [COMPOSE FILE NAME] down
Docker Build ¶
-
Build docker image using Dockerfile
docker build -t [IMAGE NAME:TAG_ID] .
Reference: