Back to blog
Jul 01, 2024
2 min read

Working with Docker Image and Containers

Introduce Docker Image and Containers, also list the common used commandline.

Advantages and Disadvantages of Containers

img01

Docker image: A read-only template containing all the necessary files, libraries, and dependencies required to run an application in a Docker container

Docker container: A running instance of an image. That is, an executable package including the code, libraries, and dependencies needed to run the application

Dockerfile: A script containing instructions to create the image you should use root account or sudo plus some docker commands to run these command lines.

Display Docker version

docker --version

Display Docker system info

docker info

img02

Get help on Docker

docker --help

img03

Run a container It should use docker run {container name}, currently I want to use hello-world as container name.

docker run hello-world

img04

List all running containers

docker ps

List all containers

docker ps --all

img05

Pull an image from a registry with docker pull {image}

docker pull ubuntu

img06

docker start --interactive --attach ubuntu

this command is used to start an existing Docker container in an interactive mode and attach your terminal’s standard input, output, and error streams to the container.

Stop a container with docker stop {container ID}

docker stop {container ID}

img07

Kill and remove a container

docker rm --force {container ID}

img08