Introduction to Docker

📒 link

Overview

  • What is Docker?

    • Docker is an open platform for developing, shipping, and running applications. With Docker, you can separate your applications from your infrastructure and treat your infrastructure like a managed application.

    • Docker helps you ship code faster, test faster, deploy faster, and shorten the cycle between writing code and running code.

Hello World

✔️ Run a hello world container

docker run hello-world

✔️ Take a look at the container image

docker images

✔️ Look at the runnung containers

docker ps

If you want to see all containers, including ones that have finished executing, run docker ps -a

Build

✔️ Build a Docker image based on a simple node application.

Now build the image.

Run

✔️ Run containers based on the image you built

✔️ Stop and remove the container

✔️ Start the container in the background

✔️ Run another container with the new image version

Edit app.js

Build this new image and tag it with 0.2

Run another container

Debug

✔️ Look at the logs of a container

If you want to follow the log’s output as the container is running, use th -f option. docker logs -f [container_id]

✔️ Start an interactive Bash session inside the running container.

✔️ Examine a container’s metadata in Docker by using Docker inspect

Publish

✔️ Find your project ID by running

✔️ Tag node-app:0.2.

✔️ Push image to gcr

✔️ Check that the image exists in gcr

✔️ Stop and remove all container

Remove the child images before you remove the node image

✔️ Pull the image and run it

Summary

  • Build, run, and debug docker containers.

  • Pull Docker images from Docker Hub and Google Container Registry.

  • Push Docker images to Google Container Registry.

Last updated