No Description 1.9KB

Docker Spike

Useful commands

docker version
  • List images

    docker images
  • List containers

    docker ps -a
  • Build the image

    cd [folder-with-dockerfile]/
    docker build -t image-tag .
  • Run Image

    docker run [image-tag]
  • Add a new image from a tag

    docker tag [tag-id] [new name]
  • Remove image

    docker rmi -f [image-name-or-id]


    docker image rm -f [image-name-or-id]
  • Remove container (removes associated volumes as well)

    docker rm -f [container-id]
  • Navigate into container

    docker exec -it [container-id] bash
  • Inspect a container

    docker inspect [container-id]

Create your own image

mkdir image-name
cd image-name
touch Dockerfile
  • In the Dockerfile:

    FROM docker/whalesay:latest
    RUN apt-get -y update && apt-get install -y fortunes
    CMD /usr/games/fortune -a | cowsay
  • Build the image

    cd image-name/
    docker build -t image-tag .
  • Run the container

    docker run image-tag

Docker Compose

It is used to define and run multi-container Docker applications (with different services). By writing a docker-compose.yml file you can specify these services. Then, using a single command, you create and start all the services from your configuration.

Useful commands

  • Start docker compose

    docker-compose up
  • See logs from one docker-compose service

    docker-compose logs -f [service]