Please enable JavaScript.
Coggle requires JavaScript to display documents.
Docker (Commands (Run (docker rm -f $(docker ps -aq) - Delete all running…
Docker
Commands
Run
-
docker exec -it web bash
- create a new bash process inside the container and connect it to terminal
-
-
-
-
Basics:
:star:docker run <image>
:star:docker start <name|id>
:star:docker stop <name|id>
:star:docker ps [-a include stopped containers]
- sell all containers
:star:docker rm <name|id>
-
-
-
General
-
-
To expose Web server Port (real world) 8080 from docker Port of (80)
docker run -p 8080:80 <Image>
If want to run 5 copies - this is helpful
-
docker run -d --name web1 -p 8081:80 <IMAGE>
- run image and give it name web1 expose it on Port 8081 - (-d runs it in background daemon) - change web1 name to [2],[3] and run multiple instances of the same Image
-
Run docker image with database once database is in background
docker run -it -p 80:8080 --link some-mongo:mongo <Image>
-it means interactive
-
-
Dockerfile
-
Use nginx
Top of Docker File:
FROM nginx
RUN mkdir /etc/nginx/logs && touch /etc/nginx/logs/static.log
ADD ./nginx.conf /etc/nginx/conf.d/default.conf
ADD /src /www
(adds source code to /wwwDont need
EXPOSE 80as taken care of in Nginx
Also don't need
CMD nginx` as taken care of in Nginx
Build file and Deploy
-
-
Find IP Address - docker ip - will give IP for virtual machine
Add this to hosts file (sudo vim /etc/hosts
then add<IPADDRESS><ALIAS>
-
-
Once logged into docker (docker login
) push Dockerfile to Dockerhub
docker push <image>
- sends image to Dockerhub
Then go to server and docker run <ALL OTHER COMMANDS>
and will pull latest docker image automatically
Swarm
Commands
-
-
-
Create a service from a Image exposed on a specific port and deploy 3 instances
docker service create --replicas 3 -p 80:80 --name web nginx
-
Cluster/Cloud
10 machines of coreos/mesos (Big players/Production Large Scale)- these 2 operating systems allow all computers to act as one. Can run multiple containers on machine these types
-