Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to create a custom container in docker

Shulou Source: shulou.com Published: 2022-06-02 06:07:13 09月13日 Update

Docker how to create custom containers, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

1. Install dockerbrew cask install docker2 under docker,mac. Check whether docker has successfully installed docker-- versionDocker version 19.03.13, build 4484c46d9d3. Add a domestic mirror source for docker.

Edit: ~ / .docker/daemon.json, add the following, and then restart.

"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]4." Create a base environment image and open a container with this image.

In docker, a mirror is like the concept of a class in java, and a container is an object created with an image.

Docker images # checks all existing images. Docker run-it-- name centos centos:latest / bin/bash# create a docker image with centos as the core # docker run command launches a docker container #-it refers to the interactive mode #-name defines the container name # centos:latest is the specific image name and image tag, and defaults to the local docker image library. If the local mirror library does not exist, it will look on docker hub for # / bin/bash is the command running in interactive mode. After running the above code, it will enter the interior of the container.

Other commands about mirroring

Docker rmi id# remove Mirror

Other commands about containers

Docker ps# View now running Container docker ps-a # View all docker containers docker rm ID# Delete Container docker run-itd-- name centos / bin/bash# start Container #-d run docker start id# in the background to start a stopped container exit# exit docker export id centos.tar# export container from the container I don't think I can use this command docker cp local directory id: capacity In-device path # copy the file from the host machine to the container and read the above Have you mastered how to create custom containers in docker? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Container mirror command run content name method more pattern problem check success helpless for this interactive code reason background foundation host Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Linux MySQL Docker vpn