https://hub.docker.com/
docker pull projectfifo/ddb
docker run -p 5555:5555 -d projectfifo/ddb
docker run -p 8080:8080 -d projectfifo/dfe
docker run -p 3000:3000 -d projectfifo/grafana
docker run -d --name=grafana -p 3000:3000 grafana/grafana
docker build -t starsl/devops-django:latest .
docker run -d -p 8000:8000 --name=devops-django starsl/devops-django
docker logs -f devops-django
md5-a215d5dbf10014c3d15fb59cc93d1a5f
查看docker IP
docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
md5-a215d5dbf10014c3d15fb59cc93d1a5f
docker stats
docker rm `docker ps -a |awk '{print $1}' | grep [0-9a-z]`
docker rmi $(docker images -q)
docker update --restart=always
docker update -m 1.5G --memory-swap 3G riak02
md5-c8a4093a0d47c1cc94b3fffc3680f894
docker run -it cerl
docker commit -m "add erl make" -a "starsliao" 55ecf32d93fb cerl
md5-9653a4994c127ae99188ac47b44d4749
ExecStart=/usr/bin/dockerd --registry-mirror=http://hub-mirror.c.163.com
md5-03aef4969a6afea366d52fba5223fd33
echo -n | openssl s_client -showcerts -connect index.docker.io:443 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >>/etc/pki/tls/certs/ca-bundle.crt
md5-a215d5dbf10014c3d15fb59cc93d1a5f
#查看容器标准输出
docker logs -f 494fe496e748
#查看端口映射
docker port 494fe496e748
-P :是容器内部端口随机映射到主机的高端口。
-p : 是容器内部端口绑定到指定的主机端口。
#进入停止的容器(交互式,死循环)
docker start 494fe496e748
docker exec -it 494fe496e748 /bin/bash
或
docker attach --sig-proxy=false 494fe496e748
#docker hub查找进行
docker search nginx
docker inspect 容器ID或容器名 |grep '"IPAddress"'
运行容器
runoob@runoob:~/nginx$ docker run -p 80:80 --name mynginx -v $PWD/www:/www -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/wwwlogs -d nginx
md5-e25559d5fd0893832996e9385f7c118c
echo "192.168.220.251 fg.com">>/etc/hosts
vi /etc/docker/daemon.json
{
"registry-mirrors": [
"https://registry.docker-cn.com"
],
"dns": [
"192.168.200.245"
],
"insecure-registries": [
"fg.com"
]
}
md5-fa8aceb9d0e9800edeb9845a9636c204
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh --mirror Aliyun
systemctl enable docker
systemctl start docker
tee -a /etc/sysctl.conf <<-EOF
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
fs.file-max = 655360
vm.swappiness = 0
net.ipv4.tcp_max_syn_backlog = 40000
net.core.somaxconn = 40000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_moderate_rcvbuf = 1
EOF
sysctl -p
docker run -d -p 80:5000 -v /opt/registry:/var/lib/registry --restart=always --name registry registry
md5-9aeaaafdf17ccf3b81c5bc5412c129f4
vi /etc/docker/registry/config.yml
storage:
delete:
enabled: true
curl -v -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -X HEAD http://fg.com/v2/slot_guest/manifests/latest
curl -X DELETE http://fg.com/v2/slot_guest/manifests/sha256:46cb4407ee871dfab0cceb2dc0a7ed5358d5aa81edfa844c2ff3d10c886fa484
registry garbage-collect /etc/docker/registry/config.yml
md5-9b3b1db03f0cda18c29de3c9111a88ff
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import requests
import json
import traceback
# 仓库地址
repo_ip = 'fg.com'
repo_port = 80
# 不加此值一次无法获取到此值内所有的镜像
COUNT=3000
def isNotEmpty(s):
return s and len(s.strip()) > 0
def getImagesNames(repo_ip,repo_port):
docker_images = []
try:
url = "http://" + repo_ip + ":" + str(repo_port) + "/v2/_catalog?n=" + str(COUNT)
res =requests.get(url).content.strip()
res_dic = json.loads(res)
images_type = res_dic['repositories']
for i in images_type:
url2 = "http://" + repo_ip + ":" + str(repo_port) +"/v2/" + str(i) + "/tags/list"
res2 =requests.get(url2).content.strip()
res_dic2 = json.loads(res2)
name = res_dic2['name']
# tags = res_dic2[filter(isNotEmpty,'tags')]
tags = res_dic2['tags']
if tags not in [None]:
for tag in tags:
docker_name = str(repo_ip) + "/" + name + ":" + tag
docker_images.append(docker_name)
print(docker_name)
except:
traceback.print_exc()
return docker_images
if __name__ == '__main__':
getImagesNames(repo_ip, repo_port)