赞
踩
curl -o /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum mache
cat /etc/redhat-release
Linux Server release 7.2 (Paladin)
uname -a
Linux 4.9.151-015.3000.7.x86_64 #1 SMP Tue Mar 12 19:10:26 CST 2019 x86_64 x86_64 x86_64 GNU/Linux
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.8.tgz
tar zxvf docker-20.10.8.tgz
cp docker/* /usr/bin/
vi /etc/systemd/system/docker.service
添加内容
[Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewall.service Wants=network-online.target [Service] Type=notify #the default is not to use systemd for cgroups because the delegay issues still #exists and systemd currently does not support the cgroup feature set required #for containers run by docker ExecStart=/usr/bin/dockerd ExecReload=/bin/kill -s HUP $MAINPID #Having non-zero Limit*s causes performance problems due to accounting overhead #in the kernel. We recommend using cgroups to do container-local accounting. LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity #Uncomment TasksMax if your systemd version supports it. #Only Systemd 226 and above support this version #TasksMax=infinity TimeoutStartSec=0 #set delegate yes so that systemd does not reset the cgroups of docker containers Delegate=yes #kill only the docker process, not all process in the cgroup KillMode=process #restart the docker process if it exits prematurely Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target
配置服务
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload #重新加载配置(每次修改文件后需执行)
systemctl start docker.service
systemctl status docker.service
systemctl enable docker.service ##使服务开启自启
vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com","https://registry.docker-cn.com"]
}
service docker restart
docker info
如果想修改docker镜像路径
du -sh /var/lib/docker/
320K /var/lib/docker/
service docker stop
mkdir -p var/lib/docker
ln -s /home/xxxx/tmp/docker/var/lib/docker /var/lib/docker
service docker start
ls -ltr | grep docker
拉取镜像
docker run -d -p 6379:6379 --name redis redis:latest
#du -sh /var/lib/docker/
#240M /var/lib/docker/
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f0e742b9be40 redis:latest "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:6379->6379/tcp redis
brew not git repository
haogeoyes@B-V1WTQ05P-0318 ~ % brew install git fatal: not in a git directory Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-cask, skipping update! fatal: not in a git directory Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-core, skipping update! fatal: not in a git directory Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-services, skipping update! ==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/gettext-0.21.arm64_monterey.bottle.tar.gz Already downloaded: /Users/haogeoyes/Library/Caches/Homebrew/downloads/1de12628f1e5811fc7f479121352d4b4ef79b0747ca029098eb01dab21b5152e--gettext-0.21.arm64_monterey.bottle.tar.gz ==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/pcre2-10.40.arm64_monterey.bottle.tar.gz Already downloaded: /Users/haogeoyes/Library/Caches/Homebrew/downloads/1e1f0fb3ee388c2b582280953cd239d1d312b159c8f2ddf91d947d8928f7f6e6--pcre2-10.40.arm64_monterey.bottle.tar.gz ==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/git-2.37.1.arm64_monterey.bottle.tar.gz Already downloaded: /Users/haogeoyes/Library/Caches/Homebrew/downloads/aa30898350ce97da434638ba666a3b2b293f7db316ba17e092632a049bda3abe--git-2.37.1.arm64_monterey.bottle.tar.gz ==> Installing dependencies for git: gettext and pcre2 ==> Installing git dependency: gettext fatal: not in a git directory Error: Command failed with exit 128: git 此原因是因为brew 配置问题 haogeoyes@B-V1WTQ05P-0318 ~ % brew -v Homebrew 3.5.7-11-g8a153de fatal: unsafe repository ('/opt/homebrew/Library/Taps/homebrew/homebrew-core' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core Homebrew/homebrew-core (no Git repository) fatal: unsafe repository ('/opt/homebrew/Library/Taps/homebrew/homebrew-cask' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask Homebrew/homebrew-cask (no Git repository)
解决此问题先创建目录
haogeoyes@B-V1WTQ05P-0318 ~ % mkdir /opt/homebrew/Library/Taps/homebrew/homebrew-cor
haogeoyes@B-V1WTQ05P-0318 ~ % mkdir /opt/homebrew/Library/Taps/homebrew/homebrew-cask
mkdir: /opt/homebrew/Library/Taps/homebrew/homebrew-cask: File exists
haogeoyes@B-V1WTQ05P-0318 ~ % git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
haogeoyes@B-V1WTQ05P-0318 ~ % git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
docker ps docker images docker search golang docker pull golang docker pull redis docker rmi -f golang Untagged: golang:latest Untagged: golang@sha256:c72fa9afc50b3303e8044cf28fb358b48032a548e1825819420fd40155a131cb Deleted: sha256:276895edf9673267f47528e8a99401f2d2947f6c9c00490f773d5ed8f559bef2 docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES bceb2d3927de 3e42dd4e79c7 "docker-entrypoint.s…" 59 minutes ago Up 59 minutes 6379/tcp nifty_black 停止虚拟机 docker stop bceb2d3927de 启动虚拟机 docker start u1 #导出 docker save redis -o redis.tar #加载 docker load -i redis.tar Loaded image: redis:latest docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 3e42dd4e79c7 3 days ago 117MB #镜像tag docker tag redis:latest redis:pro docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 3e42dd4e79c7 3 days ago 117MB redis pro 3e42dd4e79c7 3 days ago 117MB
# -it 表示 与容器进行交互式启动 -d 表示可后台运行容器 (守护式运行) --name 给要运行的容器 起的名字 /bin/bash 交互路径 docker run -it -d --name 要取的别名 镜像名:Tag /bin/bash docker run -it -d --name redis_docker redis:pro /bin/bash docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7246c5799195 redis:pro "docker-entrypoint.s…" 10 minutes ago Up 10 minutes 6379/tcp redis_docker docker rename 容器ID/容器名 新容器名 docker exec -it 容器名/容器ID /bin/bash docker attach 容器名/容器ID #-----直接退出 未添加 -d(持久化运行容器) 时 执行此参数 容器会被关闭 exit # 优雅提出 --- 无论是否添加-d 参数 执行此命令容器都不会被关闭 Ctrl + p + q docker stop 容器ID/容器名 docker restart 容器ID/容器名 docker start 容器ID/容器名 docker kill 容器ID/容器名 #从容器内 拷出 docker cp 容器ID/名称: 容器内路径 容器外路径 #从外部 拷贝文件到容器内 docker cp 容器外路径 容器ID/名称: 容器内路径 docker logs -f --tail=要查看末尾多少行 默认all 容器ID docker run -d -p 6379:6379 --name redis --restart=always -v /var/lib/redis/data/:/data -v /var/lib/redis/conf/:/usr/local/etc/redis/redis.conf redis:5.0.5 --requirepass "password" 虚拟机创建镜像 docker commit -m="提交信息" -a="作者信息" 容器名/容器ID 提交后的镜像名:Tag docker commit eafd9111ada6 docker/lua docker commit -m='pipline流水线' -a='haogeoyes' 82e18d339fff haogeoyes/jenkins:v1.2 docker push haogeoyes/jenkins:v1.2 # 删除异常停止的容器 docker rm `docker ps -a | grep Exited | awk '{print $1}'` # 删除名称或标签为none的镜像 docker rmi -f `docker images | grep '<none>' | awk '{print $3}'` 查找大文件 find / -type f -size +100M -print0 | xargs -0 du -h | sort -nr 查找制定大小we年 find / -type f -size +100M -print0 | xargs -0 du -h | sort -nr |grep '/var/lib/docker/overlay2/*'
docker rmi -f imagename
cd /var/lib/docker
rm -fr *
docker ps -a
docker search centos
docker pull search
# docker run -it -d --name test centos /bin/bash
docker attach 44fc0f0582d9
docker exec -it 23 /bin/bash
docker -itd centos
docker run -di -v /var/lib/docker:/mnt -p 6666:6666 centos
docker exec -it 1c63a9800e7c /bin/bash
空间占用
#docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 27 24 7.538GB 3.407GB (45%) 镜像
Containers 57 19 1.824GB 1.824GB (99%) 容器
Local Volumes 11 2 460B 460B (100%) 本地卷
Build Cache 0 0 0B 0B 构建缓存
docker rmi -f 镜像id 强制删除镜像
docker rmi -f $(docker images -qa)
docker 的虚悬镜像:仓库名、标签名都是的镜像 ,俗称dangling image
docker pull centos:centos7
wget -O ./CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
docker build -t gozero:v1 .
java 应用部署
Dockerfile
FROM openjdk:8-jdk-slim # 源镜像
LABEL maintainer=haogeoyes # 作者
COPY target/*.jar /app.jar
ENTRYPOINT ["java","-jar","java-demo-0.0.1-SNAPHOT.jar"] # 启动命令
docker build -t java-demo:v1.0 -f Dockerfile . # 当前目录下工作
docker build -t python:v3.ali -f Dockerfile-python3 . # 构建python3镜像
gozero安装
FROM centos:centos7 RUN yum -y install wget RUN wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo RUN wget -O /etc/yum.repos.d/go-repo.repo https://mirror.go-repo.io/centos/go-repo.repo # RUN yum clean all # RUN yum makecache RUN yum -y install go RUN mkdir -p /root/go/bin RUN go env -w GO111MODULE=on RUN go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct RUN go install github.com/zeromicro/go-zero/tools/goctl@latest https://gitee.com/kevwan/go-zero/tree/master/tools/goctl vi ~/.bash_profile export PATH=$PATH:/Users/chenhaohao/go/bin source ~/.bash_profile wget https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-osx-x86_64.zip yum -y install unzip unzip protoc-21.4-osx-x86_64.zip mv bin/protoc ../go/bin/ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest wget https://github.com/protocolbuffers/protobuf/releases/download/v21.4/protoc-21.4-osx-x86_64.zip
docker build -t gozero:v1 .
虚拟机备份镜像
docker export 379 > 虚拟机镜像.tar
导入镜像
cat 虚拟机镜像.tar | docker import - redis:3.7
直接docker 备份
docker commit 85e12a9736b7 gozero:latest
启动虚拟机
docker run -itd -v /var/lib/docker:/data -p 6666:6666 gozero
docker system df 查看占用空间 docker system prune -a 清理无用空间 docker logs xxxx -f 动态跟踪日志 docker pull centos docker pull ubuntu 启动交互式容器 docker run --name=“容器名字” -d 后台 -i 交付时 -t伪终端 同时使用 -P 随机端口映射 -p 指定端口映射 docker run -itd ubuntu /bin/bash docker run -it --name=chh ubuntu /bin/bash docker exec -it 379 bin/bash exit 退出 ctrl + p + q 退出不停止容器 进入容器 docker attach 进入容器启动命令的终端,exit退出会导致容器停止 exec 打开新的终端,ctr p q 可以启动新的进程exit退出 #docker ps | grep ubun 867b15b4b343 ubuntu "/bin/bash" 17 seconds ago Up 16 seconds chh 379abc0f446b ubuntu "/bin/bash" 2 minutes ago Up 2 minutes fervent_black 删除退出容器 docker rm -f $(docker ps -a -q) #docker ps -a | grep Exit | awk '{print $1}' | xargs docker rm fe13e90001b6 867b15b4b343 11abcc9fcd48 5b2ce5e429b4 d8d91b4b9dc8 docker ps -a | grep Created | awk '{print $1}' | xargs docker rm -f 查看容器内进程 #docker top 379 UID PID PPID C STIME TTY TIME CMD root 84724 84683 0 Sep05 ? 00:00:00 /bin/bash
#docker inspect 379
[ { "Id": "379abc0f446ba3a2b4e97d270f93fe171ee0f1b610933c2a9d0c09b029c8ada3", "Created": "2022-09-05T09:38:01.265151728Z", "Path": "/bin/bash", "Args": [], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 84724, "ExitCode": 0, "Error": "", "StartedAt": "2022-09-05T09:38:01.684584424Z", "FinishedAt": "0001-01-01T00:00:00Z" }, "Image": "sha256:ba6acccedd2923aee4c2acc6a23780b14ed4b8a5fa4e14e252a23b846df9b6c1", "ResolvConfPath": "/home/tianyan/tmp/docker/var/lib/docker/containers/379abc0f446ba3a2b4e97d270f93fe171ee0f1b610933c2a9d0c09b029c8ada3/resolv.conf", "HostnamePath": "/home/tianyan/tmp/docker/var/lib/docker/containers/379abc0f446ba3a2b4e97d270f93fe171ee0f1b610933c2a9d0c09b029c8ada3/hostname", "HostsPath": "/home/tianyan/tmp/docker/var/lib/docker/containers/379abc0f446ba3a2b4e97d270f93fe171ee0f1b610933c2a9d0c09b029c8ada3/hosts", "LogPath": "/home/tianyan/tmp/docker/var/lib/docker/containers/379abc0f446ba3a2b4e97d270f93fe171ee0f1b610933c2a9d0c09b029c8ada3/379abc0f446ba3a2b4e97d270f93fe171ee0f1b610933c2a9d0c09b029c8ada3-json.log", "Name": "/fervent_black", "RestartCount": 0, "Driver": "overlay2", "Platform": "linux", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": null, "HostConfig": { "Binds": null, "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "default", "PortBindings": {}, "RestartPolicy": { "Name": "no", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "CapAdd": null, "CapDrop": null, "CgroupnsMode": "host", "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "private", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "ConsoleSize": [ 0, 0 ], "Isolation": "", "CpuShares": 0, "Memory": 0, "NanoCpus": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": [], "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DeviceCgroupRules": null, "DeviceRequests": null, "KernelMemory": 0, "KernelMemoryTCP": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": null, "OomKillDisable": false, "PidsLimit": null, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0, "MaskedPaths": [ "/proc/asound", "/proc/acpi", "/proc/kcore", "/proc/keys", "/proc/latency_stats", "/proc/timer_list", "/proc/timer_stats", "/proc/sched_debug", "/proc/scsi", "/sys/firmware" ], "ReadonlyPaths": [ "/proc/bus", "/proc/fs", "/proc/irq", "/proc/sys", "/proc/sysrq-trigger" ] }, "GraphDriver": { "Data": { "LowerDir": "/home/tianyan/tmp/docker/var/lib/docker/overlay2/b63dd2960cba2dcd0baa2d60fd761cea352a472e85d2038d04562946c071ffd3-init/diff:/home/tianyan/tmp/docker/var/lib/docker/overlay2/57db8b633ef282029ba46e19e4fa9641863672a46b3862f10a332f35f66c747f/diff", "MergedDir": "/home/tianyan/tmp/docker/var/lib/docker/overlay2/b63dd2960cba2dcd0baa2d60fd761cea352a472e85d2038d04562946c071ffd3/merged", "UpperDir": "/home/tianyan/tmp/docker/var/lib/docker/overlay2/b63dd2960cba2dcd0baa2d60fd761cea352a472e85d2038d04562946c071ffd3/diff", "WorkDir": "/home/tianyan/tmp/docker/var/lib/docker/overlay2/b63dd2960cba2dcd0baa2d60fd761cea352a472e85d2038d04562946c071ffd3/work" }, "Name": "overlay2" }, "Mounts": [], "Config": { "Hostname": "379abc0f446b", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "Tty": true, "OpenStdin": true, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "Cmd": [ "/bin/bash" ], "Image": "ubuntu", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": {} }, "NetworkSettings": { "Bridge": "", "SandboxID": "ded90d948611c7ab91939bb3ca39a8cfe77d0b02e740920320529a08f4a36f0c", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": {}, "SandboxKey": "/var/run/docker/netns/ded90d948611", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "38dfa70fd51559c35d86f9893d700a3fd16ed73d1d2666620dfc34a925a56fe0", "Gateway": "172.17.0.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "MacAddress": "02:42:ac:11:00:02", "Networks": { "bridge": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "d656231de20d84c89463cbada216ce2362833c9b1fc135428690b1a018c8f247", "EndpointID": "38dfa70fd51559c35d86f9893d700a3fd16ed73d1d2666620dfc34a925a56fe0", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:02", "DriverOpts": null } } } } ]
查看docker日志 docker lgos c9db #docker ps | grep redis c9db90e706cc redis "docker-entrypoint.s…" 10 days ago Up 10 days k8s_test-k8s_test-pod_default_0a4e6e4e-6326-4f7d-b7be-2a5e1243a34c_0 [root@diagnosis-tool011164062250.na62 /root] Sky_Eye_System_Unline_250_master #docker exec -it c9 /bin/bash root@test-pod:/data# root@test-pod:/data# root@test-pod:/data# redis-cli -p 6379 127.0.0.1:6379> ping PONG 127.0.0.1:6379> set a b OK 127.0.0.1:6379> get a docker 拷贝文件 docker cp 容器id:路径 目标主机路径 docker cp /root/sa_install.log 379:/
docker pull ubuntu
分层下载, UnionFS 联合文件系统:分层、轻量聚合挂载文件系统
docker bootfs 引导区文件系统 bootloader 内核 kernel
分层的目的,资源共享,方便迁移复用
提交容器副本 生成新镜像
dokcer commit -m=“我的镜像” -a="作者"
docker commit -m = "add vim" -a ="haogeoyes" 369xxxx3920 haogeoyes/gozero:1.1
登录阿里云镜像仓库 #docker login --username=haogeoyes registry.cn-hangzhou.aliyuncs.com Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded 上传镜像 docker tag 359xxxx registry.cn-hangzhou.aliyuncs.com/haogeoyes/gozero:1.1 docker push registry.cn-hangzhou.aliyuncs.com/haogeoyes/gozero:1.1 拉取镜像 docker pull registry.cn-hangzhou.aliyuncs.com/haogeoyes/gozero:1.1
docker 私有仓库
搭建本地镜像仓库 docker pull registry 下载 仓库源镜像 只有26M #docker pull registry Using default tag: latest latest: Pulling from library/registry 79e9f2f55bf5: Pull complete 0d96da54f60b: Pull complete 5b27040df4a2: Pull complete e2ead8259a04: Pull complete 3790aef225b9: Pull complete Digest: sha256:169211e20e2f2d5d115674681eb79d21a217b296b43374b8e39f97fcf866b375 Status: Downloaded newer image for registry:latest docker.io/library/registry:latest 下载镜像 启动镜像源 #docker run -d -p 5000:5000 -v /home/tmp:/tmp/registry --privileged=true registry cdf80c9eff8896092cab82901ad04d170f58dfc50868f79d9753643891d3f1ac 挂在目录经常出现 open directory : Permission denied --privileged=true 具备root权限 #docker ps | grep reg cdf80c9eff88 registry "/entrypoint.sh /etc…" 44 seconds ago Up 43 seconds 0.0.0.0:5000->5000/tcp angry_matsumoto #curl -XGET http://127.0.0.1:5000/v2/_catalog {"repositories":[]} 推送镜像到本地私服库 克隆镜像 docker tag gozero:1.2 127.0.0.1:5000/gozero:1.2 默认不允许http方式推送镜像,告诉本机的5000端口私服库是安全的 vi /etc/docker/daemon.json "insecure-registries":["127.0.0.1:5000"] 重启docker systemctl restart docker 推送 docker push 127.0.0.1:5000/gozero:1.2 测试: docker tag ubuntu:latest 11.xx.xx.250:5000/ubuntu:1.1 #docker push 11.xx.xx.250:5000/ubuntu Using default tag: latest The push refers to repository [11.xx.xx.250:5000/ubuntu] Get "https://11.xx.xx.250:5000/v2/": http: server gave HTTP response to HTTPS client #docker push 11.xx.xx.250:5000/ubuntu:1.1 The push refers to repository [11.xx.xx250:5000/ubuntu] 9f54eef41275: Pushed 1.1: digest: sha256:7cc0576c7c0ec2384de5cbf245f41567e922aab1b075f3e8ad565f508032df17 size: 529 验证镜像 #curl -XGET http://127.0.0.1:5000/v2/_catalog {"repositories":["ubuntu"]} 删除镜像 #docker rmi -f 11.164.62.250:5000/ubuntu:1.1 Untagged: 11.164.62.250:5000/ubuntu:1.1 Untagged: 11.164.62.250:5000/ubuntu@sha256:7cc0576c7c0ec2384de5cbf245f41567e922aab1b075f3e8ad565f508032df17 拉取本地私服镜像 docker pull 11.xx.xx.250:5000/ubuntu:1.1
容器数据卷持久化 -v /tmp:/tmp --privileged=true ubuntu
只读 -v /tmp:/tmp:ro ubuntu
docker inspect 379
mount 挂载目录
容器卷 继承
docker run -it --privileged=true --v /tmp:/tmp --name u1 ubuntu
docker run -it --privileged=true --volumes-from u1 --name u2 ubuntu
docker 镜像部署过程
搜索、拉取、查看、启动、停止、移除
docker run -d -p 8080:8080 --name t1 tomcat
docker run -d -P --name t1 tomcat
docker run -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7
mysql -uroot -p
数据库目录挂在卷
docker run -d -p 3306:3306 --privileged=true
-v /mysql/log:/var/log/mysql
-v /mysql/data:/var/lib/mysql
-v /mysql/conf:/etc/mysql/conf.d
-e MYSQL_ROOT_PASSWORD=123456 --name mysql mysql:5.7
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。