Docker:是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的、可移植的、自给自足的容器。开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VMs(虚拟机)、bare metal、OpenStack 集群和其他的基础应用平台。
http://www.docker.org.cn/page/resources.html
完全卸载:
sudo yum list installed|grep docker
sudo yum remove containerd.io.x86_64 docker-ce.x86_64 docker-ce-cli.x86_64
sudo rm /etc/yum.repos.d/docker*.repo
sudo rm -rf /etc/systemd/system/docker.service.d
sudo rm -rf /var/lib/docker
sudo rm -rf /var/run/docker
sudo rm -rf /run/docker
sudo rm -rf /etc/docker
最新安装:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache fast
sudo yum -y install docker-ce
sudo systemctl start docker
sudo systemctl enable docker
vim /etc/docker/daemon.json
{
“registry-mirrors”:[“your accelerate address”]
}
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
systemctl daemon-reload
systemctl restart docker
sudo docker pull centos:7
常用命令:
sudo docker search centos --filter "is-official=true" # 显示官方
sudo docker search centos--stars=3 # 过滤热度
sudo docker images
sudo docker rmi image id/tag
启动docker:systemctl start docker
停止docker:systemctl stop docker
重启docker:systemctl restart docker
查看docker状态:systemctl status docker
sudo docker run --name mydocker -it centos:7 /bin/bash
sudo docker stop
sudo docker ps
sudo docker ps -a
sudo docker rm container id
sudo docker rm -f container id
sudo docker attach [container id] #exit之后容器也退出运行了
sudo docker exec -it [container id] /bin/sh #exit之后容器还在运行中
sudo yum -y install docker # 安装docker
sudo docker pull centos:7 # 拉取centos 7版本的镜像到本地
touch dockerfile # 编辑dockerfile
sudo docker build -t test1:v1.0 #构建镜像
sudo docker run -it --rm -p 8080:8080 --privileged=true -v /home/260254/docker/testcutimg-master:/cutimages:rw --name testci test1
(r21d) root@3e84e663fe31:~# cat /etc/issue
Ubuntu 18.04.1 LTS \n \l
(r21d) root@3e84e663fe31:~# uname -r
3.10.0-957.1.3.el7.x86_64
(r21d) root@3e84e663fe31:~# cat /proc/version
Linux version 3.10.0-957.1.3.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 29 14:49:43 UTC 2018
[260254@localhost 图片]$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.6.1810 (Core)
Release: 7.6.1810
Codename: Core
sudo docker cp 在宿主机上的文件地址 容器ID:保存到容器上的某个地址
修改docker默认存储地址:/var/lib/docker
sudo systemctl stop docker
sudo mv /var/lib/docker /run/media/260254/dde9f86c-29a3-45bf-850a-5d24236399e0/docker/lib
sudo ln -s /run/media/260254/dde9f86c-29a3-45bf-850a-5d24236399e0/docker/lib/docker /var/lib/docker
sudo systemctl daemon-reload
sudo systemctl start docker
sudo docker info
ps:
[260254@localhost docker]$ df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 50G 17G 34G 33% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 54M 16G 1% /dev/shm
tmpfs 16G 18M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sda1 1014M 382M 633M 38% /boot
/dev/mapper/centos-home 57G 14G 43G 25% /home
tmpfs 3.2G 64K 3.2G 1% /run/user/1000
/dev/sdb1 1.8T 17G 1.7T 1% /run/media/260254/dde9f86c-29a3-45bf-850a-5d24236399e0
[260254@localhost docker]$ sudo fdisk -l #查看磁盘使用情况
sudo cat /etc/group | grep docker
sudo groupadd docker
sudo usermod -aG docker 260254
sudo systemctl restart docker
su root
su 260254
----------------2019.3.23--------------------------------------------------------
sudo 免密码操作权限
vim /etc/sudoers
添加:user ALL=(ALL) NOPASSWD:ALL
Or
echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
Then
. /etc/sudoers
or
source /etc/sudoers
--------------------------------2019.4.18-------commit to image and push to dockerhub-------------------
docker commit [container id] [your image name:tag name]
root@slave2:/home/zhong# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: kuochung
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
root@slave2:/home/zhong# docker tag c3d_keras:v2 kuochung/c3d_keras:v2
root@slave2:/home/zhong# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
kuochung/c3d_keras v2 a9712ed3202d About an hour ago 39.6GB
c3d_keras v2 a9712ed3202d About an hour ago 39.6GB
root@slave2:/home/zhong# docker push kuochung/c3d_keras:v2
-------------2019.4.27----------images的导入与导出------------------
kuochung@ubuntu:/$ sudo docker save -o ./c3d_keras_gpu.tar kuochung/c3d_keras_gpu:v3
zhong@slave2:~$ docker load --input ./c3d_keras_gpu.tar