Sunday, July 2, 2017

Docker

Download and install docker to the Mac's Applications folder and double-click the app to start the docker app.

Start nginex and mongo then kill and restart the nginex container.


$ docker --version
Docker version 17.06.0-ce, build 02c1d87                                                      

$ docker container run --publish 80:80 --detach --name webhost nginx
Unable to find image 'nginx:latest' locally                                                   
latest: Pulling from library/nginx                                                            
e6e142a99202: Pull complete                                                                   
8c317a037432: Pull complete                                                                   
af2ddac66ed0: Pull complete                                                                   
. . .                                                                                         
Digest: sha256:72c7191585e9b79cde433c89955547685db00f3a8595a750339549f6acef7702               
Status: Downloaded newer image for nginx:latest                                               
. . .                                                                                         

$ docker run --name mongo -d mongo
Unable to find image 'mongo:latest' locally                                                   
latest: Pulling from library/mongo                                                            
f5cc0ee7a6f6: Pull complete                                                                   
d99b18c5f0ce: Pull complete                                                                   
. . .                                                                                         
Digest: sha256:f1ae736ea5f115822cf6fcef6458839d87bdaea06f40b97934ad913ed348f67d               
Status: Downloaded newer image for mongo:latest                                               
. . .                                                                                         

$ docker container ls
CONTAINER ID    IMAGE   COMMAND         CREATED       STATUS      PORTS               NAMES   
9f9664b60869    mongo   "docker-en..."  31 sec ago    Up 31 sec   27017/tcp           mongo   
5c1b751f6002    nginx   "nginx -g ..."  41 sec ago    Up 40 sec   0.0.0.0:80->80/tcp  webhost 

$ docker container stop 5c1

$ docker start webhost

Start mysql

$ docker container run -d -p 3306:3306 --name mysql -e MYSQL_RANDOM_ROOT_PASSWORD=yes mysql

Unable to find image 'mysql:latest' locally                                                     
latest: Pulling from library/mysql                                                              
9f0706ba7422: Downloading [===============>                                 ]  16.22MB/52.61MB  
2290e155d2d0: Download complete                                                                 
547981b8269f: Download complete                                                                 
. . .                                                                                           

$ docker container ls -a

CONTAINER ID    IMAGE   COMMAND         CREATED       STATUS      PORTS                  NAMES  
9f9664b60869    mongo   "docker-en..."  31 sec ago    Up 31 sec   27017/tcp              mongo  
5c1b751f6002    nginx   "nginx -g ..."  41 sec ago    Up 40 sec   0.0.0.0:80->80/tcp     webhost
290328842bfd    mysql   "docker-en..."  11 sec ago    Up 10 sec   0.0.0.0:3306->3306/tcp mysql  

Start Apache

$ docker container run -d --name webserver -p 8080:80 httpd

$ docker container ls -a

CONTAINER ID    IMAGE   COMMAND         CREATED       STATUS      PORTS                  NAMES    
6d2bcc3750f6    httpd   "httpd-for..."  10 sec ago    Up 11 sec   0.0.0.0:8080->80/tcp   webserver
290328842bfd    mysql   "docker-en..."  11 sec ago    Up 20 sec   0.0.0.0:3306->3306/tcp mysql    
9f9664b60869    mongo   "docker-en..."  31 sec ago    Up 41 sec   27017/tcp              mongo    
5c1b751f6002    nginx   "nginx -g ..."  41 sec ago    Up 50 sec   0.0.0.0:80->80/tcp     webhost