forked from BretFisher/udemy-docker-mastery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.txt
213 lines (153 loc) · 6.74 KB
/
commands.txt
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
docker container start
docker container stop
docker container start -ai ubuntu
docker container run -d --name mysql -e MYSQL_RANDOM_ROOT_PASSWORD=true mysql
docker container run -d -p 80:80 --name nginx nginx
docker container top mysql
docker container inspect mysql
docker container stats
docker container ls
docker container ls -a
docker container run -it
docker container run -it --name ubuntu ubuntu
docker container start -ai ubuntu
docker container start ubuntu
docker container exec -it mysql bash (will keep the container running)
docker pull alpine
docker image ls
docker container run -p
docker container run -p 80:80 --name webhost -d nginx
docker container port webhost
docker container inspect --format '{{.NetworkSettings.IPAddress}}' webhost
docker network ls
docker network inspect
docker network create my_app_net
docker network create --driver
docker network connect
docker network disconnect
docker container run -d --name new_nginx --network my_app_net nginx
docker network connect 31a99139737606ab a19d3ce52813751
docker network connect NewNetWorkID ContainerID
docker container inspect new_nginx
docker network disconnect 5994a395cad15ffabbc 763e6555724552aa1
docker network connect NewNetWorkID ContainerID
docker container inspect webhost
docker container run -d --name my_nginx --network my_app_net nginx
docker container exec -it my_nginx ping new_nginx
docker container run --rm -it centos:7 bash
docker network create dude
docker run -d --net dude --net-alias search elasticsearch:2
docker run -d --net dude --net-alias search elasticsearch:2
docker container run --rm --net dude alpine nslookup search
docker container run --rm --net dude centos curl -s search:9200
docker image ls
docker history nginx:latest
docker history mysql
docker image tag nginx godomainz/nginx
docker image tag godomainz/nginx godomainz/nginx:testing
docker image build -t customnginx .
docker volume ls
docker container run -d --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=true -v mysql-db:/var/lib/mysql mysql
docker volume inspect mysql-db
docker volume create --help
docker container run -d --name psql1 -v psql-db:/var/lib/postgresql/data postgres:9.6.1
Bind Mounting
docker container run -v /users/akila/stuff:/path/container (mac/linux)
docker container run -v //users/akila/stuff:/path/container (windows)
docker container run -d --name nginx -p 80:80 -v $(pwd):/usr/share/nginx/html nginx
docker container run -d --name nginx -p 80:80 -v ${pwd}:/usr/share/nginx/html nginx
docker container run -d --name nginx -p 80:80 -v /${pwd}:/usr/share/nginx/html nginx
docker run -p 80:4000 -v $(pwd):/site bretfisher/jekyll-serve
docker-compose up
docker-compose up -d
docker-compose logs
docker-compose ps
docker-compose top
docker-compose down
docker-compose down -v
docker-compose down -v --rmi local
Docker Swarm
docker-machine ls
docker-machine create
docker swarm init
docker swarm init --advertise-addr $(docker-machine ip default)
docker node ls
docker swarm init --advertise-addr
docker service create alpine ping 8.8.8.8
docker service ls
docker service ps epic_neumann
docker service update epic_neumann --replicas 3
docker service rm epic_neumann
docker swarm init
docker swarm join
docker node ls
docker node update --role manager node2
docker swarm join-token manager
docker service create --replicas 3 alpine ping 8.8.8.8
docker node ps
docker node ps node3
docker service ps psql
docker network create --driver overlay mydrupal
docker service create --name psql --network mydrupal -e POSTGRES_PASSWORD=mypass postgres
docker service ls
docker service ps psql
docker service create --name drupal --network mydrupal -p 80:80 drupal
docker service create --name nginx --network mydrupal -p 8080:80 nginx
docker service inspect drupal
docker service create --name search --replicas 3 -p 9200:9200 elasticsearch:2
docker network create --driver overlay backend
docker network create --driver overlay frontend
docker service create --name vote --network frontend --replicas 2 -p 80:80 dockersamples/examplevotingapp_vote:before
docker service create --name redis --network frontend redis:3.2
docker service create --name worker --network frontend --network backend dockersamples/examplevotingapp_worker
docker service create --name db --network backend --mount type=volume,source=db-data,target=/var/lib/postgresql/data postgres:9.4
docker service create --name result --network backend -p 5001:80 dockersamples/examplevotingapp_result:before
docker stack deploy -c example-voting-app-stack.yml voteapp
docker stack ps voteapp
docker stack services voteapp
docker network ls
docker secret create psql_user psql_user.txt
echo "myDBpassword" | docker secret create psql_pass -
docker secret ls
docker service create --name psql --secret psql_user --secret psql_pass -e POSTGRES_PASSWORD_FILE=/run/secrets/psql_pass -e POSTGRES_USER_FILE=/run/secrets/psql_user postgres
docker service update --secret-rm
docker stack deploy -c docker-compose.yml mydb
docker stack rm mydb
echo "myDBpassword" | docker secret create psql-pw -
docker stack deploy -c docker-compose.yml mydrupal
windows
echo password | docker secret create psql_pass3 -
docker stack deploy -c docker-compose.yml mydrupal
echo|set /p="Hello World"
docker-compose exec psql cat /run/secrets/psql_user
docker-compose -f docker-compose.yml -f docker-compose.test.yml up -d
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up config > output.yml
docker service update --image myapp:1.2.1 <servicename>
docker service update --env-add NODE_ENV=production --publish-rm 8080 web
docker service scale web=8 api=6
docker service update --publish-rm 8080 --publish-add=9080:80 web
docker service update --force web
docker container run \
--health-cmd="curl -f localhost:9200/_cluser/health || false" \
--health-interval=5s \
--health-retries=3 \
--health-timeout=2s \
--health-start-period=15s \
elasticsearch:2
HEALTHCHECK curl -f http://localhost/ || false
HEALTHCHECK --timeouts=2s --interval=3s --retries=3 \
CMD curl -f http://localhost/ || exit 1
docker service create --name p2 --health-cmd"pg_isready -U postgres || exit 1" postgres
Run the registry image
docker container run -d -p 5000:5000 --name registry registry
Re-tag an existing image and push it to your new registry
docker tag hello-world 127.0.0.1:5000/hello-world
docker push 127.0.0.1:5000/hello-world
Remove that image from local cache and pull it from new registry
docker image remove hello-world
docker image remove 127.0.0.1:5000/hello-world
docker pull 127.0.0.1:5000/hello-world
Re-create registry using a bind mount and see how it stores data
docker container run -d -p 5000:5000 --name registry -v $(pwd)/registry-data:/var/lib/registry registry
jenkins
sudo docker run -d -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home --name jenkins jenkins/jenkins