Skip to content

Instantly share code, notes, and snippets.

@CagriAldemir
Created October 13, 2020 18:50
Show Gist options
  • Save CagriAldemir/822187a90cd8f66c8c436dc745626fbb to your computer and use it in GitHub Desktop.
Save CagriAldemir/822187a90cd8f66c8c436dc745626fbb to your computer and use it in GitHub Desktop.

Docker CLI Commands

Build Image from Dockerfile
docker build --tag <image-name>:<tag> <dockerfile-path>

#EXAMPLE
docker build --tag my-image:1.2.3 .
#or
docker build --tag my-image:1.2.3 ./dockerfile
Run Container
docker run -p <docker-host-port>:<container-port> <image-id or image-name:tag>

#EXAMPLE
docker run -p 8080:80 abc123def456
Connect to Terminal of Running Container
docker exec -it <container-id> /bin/bash

#EXAMPLE
docker exec -it abc123def456 /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment