I made a memorandum at work, so for private use It may be wrong because it is a scribble.
# docker images
# docker pull <Repository>:<tag>
If you want an image of centOs8, the repository is centos, the tag is 8 and "centos: 8".
# docker commit <container> <Repository>:<tag>
# docker rmi <Repository>:<tag> or <Image ID>
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>
List of running containers
# docker ps
List of all containers
# docker ps -a
# 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
# 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-up
# docker start <Container name>
Stop
#docker stop <Container name>
# 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