forked from qinshulei/ubuntu-cheat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker
105 lines (76 loc) · 2.43 KB
/
docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# docker build image
docker build -t vieux/apache:2.0 .
# run docker container
docker run -d -p 8080:8080 -p 50000:50000 \
--name myjenkins
--restart=always \
-v ${jenkins_location}/jenkins_home:/var/jenkins_home \
jenkins
# Link container
docker run --name CONTAINER
docker run -d --link CONTAINER:ALIAS --name LINKED user/wordpress
docker rm --link
# see image
docker image
# see running container
docker ps
# see all container
docker ps -a
# stop restart start container
docker start ${container_id}
docker restart ${container_id}
docker stop ${container_id}
# rm image
docker rmi ${image_name}
# rm container
docker rm ${container_id}
# download image
docker pull jenkins
# save image
docker save jenkins > jenkins.tar
docker save -o fedora-all.tar fedora
# store image
docker load < jenkins.tar
docker load --input fedora.tar
# docker cp files
docker cp foo.txt mycontainer:/foo.txt
docker cp mycontainer:/foo.txt foo.txt
# install docker
curl -fsSL https://get.docker.com/ | sh
# 4 ways to goto docker container's shell
sudo docker exec -it 665b4a1e17b6 /bin/bash
# docker run command as a user
docker exec -ti --user www-data e25659a8fdfc ./occ
# add docker group
sudo usermod -aG docker qinshulei
# install registry
docker run -d -p 5000:5000 --restart=always --name registry \
-v `pwd`/data:/var/lib/registry \
registry:2
# Registry Command
# Get any image from the hub and tag it to point to your registry:
docker pull ubuntu && docker tag ubuntu localhost:5000/ubuntu
# ... then push it to your registry:
docker push localhost:5000/ubuntu
# ... then pull it back from your registry:
docker pull localhost:5000/ubuntu
# To stop your registry, you would:
docker stop registry && docker rm -v registry
# show docker infomation , for example : root dir, cpu info
docker info
# docker query container info
docker inspect --format '{{.State.Pid}}' CONTAINER_ID
docker inspect --format '{{ .NetworkSettings.IPAddress }}' CONTAINER_ID
# search image
docker search jenkins
# run mysql
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d -v /data:/var/lib/mysql mysql
# look docker file
docker exec mysql cat /etc/mysql/my.cnf
# run docker-compose app
docker-compose up -d
# run bash
sudo docker run -a stdin -a stdout -i -t ubuntu /bin/bash
# for our docker registry, error like : docker tls: oversized record received with length
vi /etc/default/docker
DOCKER_OPTS="--insecure-registry 192.168.65.56:5000