docker中文网站:http://www.docker.org.cn/book/docker/what-is-docker-16.html
镜像: is an executable package that includes everything needed to run an application–the code, a runtime, libraries, environment variables, and configuration files.
容器: is launched by running an image,is a runtime instance of an image–what the image becomes in memory when executed (that is, an image with state, or a user process)
# step 1: 安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新并安装 Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce
#卸载旧的版本
rpm -qa |grep docker |xargs -n 1 rpm -e --nodeps
#1, 配置docker下载资源
yum -y install yum-utils device-mapper-persisten-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum list docker-ce
###docker.repo
# [dockerrepo]
# name=Docker Repository
# baseurl=https://yum.dockerproject.org/repo/main/centos/7/
# enabled=1
# gpgcheck=1
# gpgkey=https://yum.dockerproject.org/gpg
####docker-ce.repo
# [docker-ce-stable]
# name=Docker CE Stable - $basearch
# baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/$basearch/stable
# enabled=1
# gpgcheck=1
# gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
#2, 下载安装docker
yum -y install docker-ce
systemctl start docker
systemctl enable docker
#3,查看安装后的dock版本信息
docker version
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
在阿里云注册docker仓库: https://cr.console.aliyun.com
# repo addr: registry.cn-beijing.aliyuncs.com/docker_eyeofeagle/
sudo docker login --username=18010031897 registry.cn-beijing.aliyuncs.com
镜像加速 local config :
#1,创建配置文件
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://yywkvob3.mirror.aliyuncs.com"]
}
EOF
#或者编辑 /usr/lib/systemd/system/docker.service文件
#ExecStart=/usr/bin/dockerd --insecure-registry a.a.a.a:5000 --registry-mirrors https://yywkvob3.mirror.aliyuncs.com
#2, 重启docker服务
#sudo systemctl daemon-reload
#sudo systemctl restart docker
service docker restart
# 3, 查看配置是否生效
################# docker info 显示的前后变化############
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors: ##### 新增了一条信息###########
https://yywkvob3.mirror.aliyuncs.com/ ##### 新增了一条信息###########
Live Restore Enabled: false
Product License: Community Engine
root@wang-GA-MA770T-UD3P:/home/wang/txt# docker images |grep registry.cn-beijing.aliyuncs.com/kube_eyeofeagle/ |awk '{print $1":"$2}'
registry.cn-beijing.aliyuncs.com/kube_eyeofeagle/kube-proxy:v1.13.1
root@wang-GA-MA770T-UD3P:/home/wang/txt# docker images |grep registry.cn-beijing.aliyuncs.com/kube_eyeofeagle/ |awk '{print $1":"$2}'|xargs -n 1 docker push
The push refers to repository [registry.cn-beijing.aliyuncs.com/kube_eyeofeagle/kube-proxy]
f9cdaf1489a0: Pushed
5fe6d025ca50: Pushed
如上有一个nginx镜像: 【 nginx latest 568c4670fa80 2 weeks ago 109MB 】
找到 IMAGE ID , 也就是568c4670fa80,运行它,创建一个新的容器
 that container to be able to reuse that name..
See 'docker run --help'.
root@wang-pc:/home/wang# lsof -i:33060
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 26152 root 4u IPv6 1439331 0t0 TCP *:33060 (LISTEN)
root@wang-pc:/home/wang# mysql -uroot -p123456 -h0.0.0.0
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can't connect to MySQL server on '0.0.0.0' (111)
root@wang-pc:/home/wang# mysql -uroot -p123456 -h0.0.0.0 -P33060
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
#修改 远程登陆权限: mysql8 语法有些不同
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
mysql> flush privileges;