Docker command memo

I made a memorandum at work, so for private use It may be wrong because it is a scribble.

○ Image-related operations

Check the list of images

# docker images

Pull image from Docker Hub

# docker pull <Repository>:<tag>

If you want an image of centOs8, the repository is centos, the tag is 8 and "centos: 8".

Creating an image from an existing container

# docker commit <container> <Repository>:<tag>

Delete image

# docker rmi <Repository>:<tag> or <Image ID>

Create an image from Dockerfile

Dockerfile


FROM centos:8

RUN dnf update

RUN dnf install -y openssh-server openssh-clients

EXPOSE 22
# docker build -t <Repository>:<tag> <Directory with Dockerfile>

○ Container operation

List of containers

List of running containers
# docker ps
List of all containers
# docker ps -a

Create a container from an image

# docker run -d --name <Container name to create> <Repository>:<tag> 

Personally used options -i Attach to STDIN of container -t Pseudo terminal assignment -d Run the container in the background and display the container ID -p Expose port -e Setting environment variables --name Container name --priviledged Grant extended privileges

# docker run --priviledged -d --name test centos:8 /sbin/init

Start container

# docker exec -it <container> /bin/bash

Start the container with bash

option -i Keep STDIN open even if not attached -t Pseudo terminal assignment

Start / stop container

Start-up
# docker start <Container name>
Stop
#docker stop <Container name>

Delete container

# docker rm <Container name>

It cannot be erased unless the container is stopped. If you want to delete what is running, you can forcibly delete it by adding the "-f" option.

Recommended Posts

Docker command memo
Docker Machine command memo
docker memo
Docker command
docker tutorial (memo)
Docker operation memo
Memorandum docker command
Docker command list
docker basic command
[Memo] docker summary
Docker command summary
Docker-compose command memo
Docker command memorandum
[Docker] Command summary
[Docker] Command list
Docker x Rails 6 (memo)
docker inspect --format memo
docker error delete command
docker command personal summary
Docker command cheat sheet
MySQL 5.7 (Docker) environment construction memo
Command memo to install xeyes in ubuntu docker environment
Decomposing the Docker run command. .. ..
Redmine (Docker) environment construction memo
Docker Compact Manual (1: Basic / Basic Command)
docker
Installing and building Docker (memo)
Docker execution memo summarized for myself
nft command memo of nf_tables (CentOS8)
Integer memo
Easy installation of Docker with snap (1 command)
kubernetes + docker
spring × docker
About Docker
Command Pattern
Lombok memo
Docker Intellij
Dockerfile memo
Iterator memo
Docker basics
corretto memo
Java memo
AWS memo
Docker installation
About Docker
Docker memorandum
Try to use docker command without sudo.
Understand Docker
Docker memorandum
Dcokerfile memo
Install Docker with WSL2 Memo ([Part 2] Docker introduction)
Command docker-compose
Ruby memo
Memo Stream
Docker + Java + SpringBoot WEB development hands-on attendance memo (2019/08/19)
Command to stop or delete all Docker resources