print ('Name: ', Juan['name'])
print ('Email: ', Juan['email'])
print ('Work: ', Juan['work'])
Name: Juan A. Cabrera Email: juan.cabrera@tu-dresden.de Work: Deutsche Telekom Chair of Communication Networks
Slides: http://comnets.bitbucket.org/docker-pbl-2016/lecture-2/
Press esc
for a menu of the slides
Slides inspired and adapted from:
Docker by Example. By:
Ganesh & Hari {ganesh|hari}(at)codeops.tech
%%bash
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest e43d811ce2f4 39 hours ago 181.4 MB dock0/arch latest 9b9558aeec5c 4 days ago 573.6 MB alpine latest baa5d63471ea 4 days ago 4.799 MB nginx <none> a5311a310510 10 days ago 181.4 MB datadog/docker-dd-agent latest f385e05e1883 6 weeks ago 301.8 MB node 5-slim c7a1798865e7 7 weeks ago 207.5 MB ubuntu latest bd3d4369aebc 8 weeks ago 126.6 MB hello-world latest c54a2cc56cbb 3 months ago 1.848 kB gophernet/mz latest 71fa98ad2324 6 months ago 126.3 MB networkstatic/iperf3 latest 6ea158fee1a7 7 months ago 125.5 MB docker/whalesay latest 6b362a9f73eb 17 months ago 247 MB
%%bash
docker search arch
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
from IPython.core.display import HTML
HTML('<a href="https://hub.docker.com/">Docker Hub</a>')
docker rmi <image-tag>
We create a container using docker run
specifically:
docker run OPTIONS <<image-tag>> CMD ARGS
docker run alpine ping 8.8.8.8
docker run -t -i ubuntu /bin/bash
-t Attach a pseudo-tty console
-i Stands for Interactive
docker run -d ubuntu /bin/sh -c "while true; do echo current date and time is: $(date); sleep 2 ; done"
-d stands for detach
docker logs <Container-Tag>
Was it one-command easy?
from IPython.display import IFrame
IFrame('https://en.wikipedia.org/wiki/Comparison_of_web_server_software#Overview', width=700, height=350)
%%bash
docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 4523 [OK] jwilder/nginx-proxy Automated Nginx reverse proxy for docker c... 854 [OK] richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable ... 301 [OK] million12/nginx-php Nginx + PHP-FPM 5.5, 5.6, 7.0 (NG), CentOS... 75 [OK] webdevops/php-nginx Nginx with PHP-FPM 60 [OK] maxexcloo/nginx-php Framework container with nginx and PHP-FPM... 58 [OK] h3nrik/nginx-ldap NGINX web server with LDAP/AD, SSL and pro... 31 [OK] bitnami/nginx Bitnami nginx Docker Image 20 [OK] gists/nginx Nginx on Alpine 8 [OK] evild/alpine-nginx Minimalistic Docker image with Nginx 8 [OK] million12/nginx Nginx: extensible, nicely tuned for better... 8 [OK] maxexcloo/nginx Framework container with nginx installed. 7 [OK] webdevops/nginx Nginx container 6 [OK] 1science/nginx Nginx Docker images based on Alpine Linux 4 [OK] drupaldocker/nginx NGINX for Drupal 3 [OK] ixbox/nginx Nginx on Alpine Linux. 3 [OK] webdevops/hhvm-nginx Nginx with HHVM 3 [OK] dock0/nginx Arch container running nginx 2 [OK] servivum/nginx Nginx Docker Image with Useful Tools 2 [OK] frekele/nginx docker run --rm --name nginx -p 80:80 -p 4... 2 [OK] xataz/nginx Light nginx image 2 [OK] blacklabelops/nginx Dockerized Nginx Reverse Proxy Server. 1 [OK] tozd/nginx Dockerized nginx. 1 [OK] unblibraries/nginx Baseline non-PHP nginx container 0 [OK] c4tech/nginx Several nginx images for web applications. 0 [OK]
docker run -d -p 80:80 nginx
-d stands for detach
-p stands for port. We basically say: "Redirect every incomming TCP packet at port 80 of the host, to the port 80 of the container"
When we use the flag -p
we "publish a port, or range of ports to the host".
Format: hostPort:containerPort
For UDP ports: hostPort:containerPort/udp
First we need to find the container
docker ps
Then, we stop it
docker stop CONTAINER_ID
Let us also delete it
docker rm CONTAINER_ID
Check that the container is not there anymore. Go to localhost:80 in your browser. You should see an error
Note: Use incognito mode. Otherwise, the browser will display the cached site.
docker run -d -p 45700:80 nginx
Now, if go in your browser to localhost:4570
Go to https://hub.docker.com/ and create an account
docker run -it ubuntu
apt update
apt install inetutils-ping
exit
docker commit -a 'Juan' -m 'ping function' a122a23fd3bb juancabre/ubu_lecture:ping
sudo docker login
sudo docker push juancabre/ubu_lecture:ping
I will do it for vim
sudo rmi juancabre/ubu_lecture:ping
docker pull juancabre/ubu_lecture:ping
docker commit -a 'Juan' -m 'ping function' a122a23fd3bb juancabre/ubu_lecture
sudo docker push juancabre/ubu_lecture
Dockerfile
=============================================
# Base image
FROM ubuntu
# The maintainer
MAINTAINER Juan Cabrera
# The actual recipee
RUN apt update;\
apt install -y vim
# Adding files
ADD https://gist.githubusercontent.com/anonymous/c966c0757f62b451bffa/raw/a15e10aa38d146bf50ee6c9d7fd851ce5bb91aee/gistfile1.txt /root/.vimrc
# The default command to run
CMD /bin/bash
docker build -t juancabre/dockerfile:vim_config .
docker run -it juancabre/dockerfile:vim_config