Skip to content
Author: Tianle Yuan (65.89%), Tianle Yuan (34.11%)

Docker command line⚓︎

Useful link for understanding Docker concepts:

I. Docker Image⚓︎

Create an image:⚓︎

  1. Create a Docker file:
    .dockerfile
    mkdir Docker_images
    cd Docker_images
    vi Dockerfile
    FROM ubuntu
    MAINTAINER simpli
    RUN apt-get update
    CMD ["echo", "Welcome to Simplilearn"]
    
  2. Build a Docker Image with Dockerfile and tag:
    Git Bash
    docker build -t simpli_image /D/Docker_images  => [location of your dockerfile]
    

image

image

image

Check the images we have:⚓︎

image

Delete some image:⚓︎

image

image

II. Docker Container⚓︎

Create a container based on the image:⚓︎

Git Bash
docker run --name simpli_container simpli_image

image

image

Display a list of launched containers:⚓︎

Git Bash
docker ps -a

image

Rename an existing container:⚓︎

Git Bash
docker rename [CONTAINER_NAME] [NEW_CONTAINER_NAME]

Pause a running container:⚓︎

Git Bash
docker pause [CONTAINER_NAME]

**Stop a running container: **⚓︎

(somehow directly deleted the container)

Git Bash
docker stop [CONTAINER_NAME]

**Restart a running container: **⚓︎

(somehow directly clear the setting of container)

Git Bash
docker stop [CONTAINER_NAME]

Removes all the stopped containers:⚓︎

Git Bash
docker container prune [OPTIONS] 

Quit and delete the running containers:⚓︎

Git Bash
exit

Remove an existing container:⚓︎

Git Bash
docker rm [CONTAINER] 

Create a new image from a container’s file changes:⚓︎

Git Bash
docker container commit [OPTIONS] [CONTAINER_ID] [NEW_IMAGE_NAME]

The sub-explanation of Docker Compose: What is Docker Compose: Example, Benefits and Basic Commands