Skip to content

Latest commit

 

History

History
99 lines (66 loc) · 1.17 KB

README.md

File metadata and controls

99 lines (66 loc) · 1.17 KB

Using Docker

Sample codes to understand how to containerize applications and use docker and docker compose.

Requirements

  • Docker
  • Docker-Compose

Try out

Build and run docker image locally

  • Navigate to image directory
cd image
  • Build image
docker build -t <image_name> .
  • List images
docker images
  • Run container
docker run -d -p <host_port>:<container_port> <image_name>
  • List containers
docker ps -a

Build and push docker image to dockerhub

  • Docker Login
docker login
  • Navigate to image directory
cd image
  • Add image version
echo '0.0.1' > VERSION
./release.sh <registry> <image_name>
  • Run container
docker pull <registry>/<image_name>
docker run -d -p <host_port>:<container_port> <registry>/<image_name>

Run docker-compose

  • Navigate to compose directory
cd compose
  • Build and run containers using docker-compose
docker-compose -f docker-compose.yaml up -d
  • Stop containers
docker-compose -f docker-compose.yaml down
  • List containers
docker ps -a