Useful Commands for Docker

From Luis Gallego Hurtado - Not Another IT guy
Jump to: navigation, search


Install Docker Machine

  • Download and install docker machine
  • Access to BIOS setup, and enable virtualisation (Vt-x) in security section, so Docker can use Hyper-V

Useful Commands for Docker

  • List all containers
docker ps
  • Run a shell into a running container
docker exec -it <CONTAINER_ID> bash
  • Create a Docker image
docker image build –t <IMAGE_NAME>:<VERSION>
  • Tag a Docker image
docker image tag <IMAGE_NAME>:<VERSION> <NEW_IMAGE_NAME><NEW_VERSION>
  • Remove unused containers
docker system prune --volumes

Working with a remote Docker images repository

  • Login the Docker client agains the remote Docker images repository
docker login <HOSTNAME>:<PORT>
  • Tag a Docker image, prefixing the Docker image remote repository, e.g.
docker image tag <HOSTNAME>:<PORT>/<IMAGE_NAME>:<VERSION>
  • Push the Docker image to the remote repository
docker push <HOSTNAME>:<PORT>/<IMAGE_NAME>:<VERSION>