1 从安装和删除语句说起
1 docker引擎安装语句
sudo apt-get install docker-ce docker-ce-cli containerd.io
2 docker引擎删除语句
sudo apt-get remove docker docker-engine docker.io containerd runc
那么什么是 docker-ce docker-ce-cli containerd.io ?
2 Docker引擎:启动-停止-查看
1 要如何启动docker引擎?
systemctl start docker 或 sudo systemctl restart docker
2 要如何关闭docker引擎?
systemctl stop docker
3 如何查看docker引擎?
systemctl status docker
3 关于docker-hub:查看-拉取-登录
1 查看码头上各个公有仓库的镜象docker search nvidia ;查看带nvidia的镜像
docker search opencv ;查看带opencv的镜像
2 拉取(下载)镜像
docker pull name-image ;从仓库查到的镜像名称
3 进入自己的私有仓库(在docker-hub上)
docker registry
4 关于Images:的镜像操作(抽取、查看、实例化)
(一)产生和消灭images:
1 从hub上拉取镜像
docker pull name-image
2 删除本地镜像
docker rmi id(镜像的标识)3 创造本地镜像
docker build -t new_image_name:tag
(二) 查看本地镜像
docker images
(三)从镜像生成容器
docker run xxxxxxxxx语句
docker run -d
docker run -d -p 5672:5672 -p 15672:15672 --name rabbitmq 80bd4b95a49d
(四)镜像和本地文件转化
4. 镜像的导入导出(不规范)
# 将本地的镜像导出
docker save -o 导出的路径 镜像id
# 加载本地的镜像文件
docker load -i 镜像文件
# 修改镜像名称
docker tag 镜像id 新镜像名称:版本
附录:docker命令集合
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default "/home/huatec/.docker")
-c, --context string Name of the context to use to connect to the daemon (overrides
DOCKER_HOST env var and default context set with "docker context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default
"info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/home/huatec/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/home/huatec/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/home/huatec/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
docker管理命令:
app* Docker App (Docker Inc., v0.9.1-beta3)
builder Manage builds
buildx* Build with BuildKit (Docker Inc., v0.6.3-docker)
config Manage Docker configs
container Manage containers
context Manage contexts
image Manage images
manifest Manage Docker image manifests and manifest lists
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
scan* Docker Scan (Docker Inc., v0.8.0)
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes