Presentation of Docker
Docker is a platform for developers and sysadmins to develop, ship, and run applications.
Docker allows you to create lightweight, portable, self-sufficient containers from any application and lets you get your code tested and deployed into production as fast as possible.
To install Docker, type:
# yum install -y docker
Until recently, Red Hat advised to stop the firewalld service because there was some incompatibility with Docker. To disable the firewalld service, type:
# systemctl disable firewalld && systemctl stop firewalld
Note: According to this bug report, this shouldn’t be necessary any more.
To enable and start Docker, type:
# systemctl enable docker && systemctl start docker
To get the installed version of Docker, type:
# docker version Client version: 1.2.0 Client API version: 1.14 Go version (client): go1.3.3 Git commit (client): 2a2f26c/1.2.0 OS/Arch (client): linux/amd64 Server version: 1.2.0 Server API version: 1.14 Go version (server): go1.3.3 Git commit (server): 2a2f26c/1.2.0
To get some additional information, type:
# docker info Containers: 1 Images: 3 Storage Driver: devicemapper Pool Name: docker-253:0-31125-pool Pool Blocksize: 64 Kb Data file: /var/lib/docker/devicemapper/devicemapper/data Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata Data Space Used: 557.4 Mb Data Space Total: 102400.0 Mb Metadata Space Used: 0.9 Mb Metadata Space Total: 2048.0 Mb Execution Driver: native-0.2 Kernel Version: 3.10.0-123.9.3.el7.x86_64 Operating System: CentOS Linux 7 (Core)
Docker Image Download
If you’ve got 1GB of free disk space on the / partition, to install a CentOS 7 distribution, type:
# docker pull centos:centos7 Pulling repository centos ae0c2d0bdc10: Download complete 511136ea3c5a: Download complete 5b12ef8fd570: Download complete
Note: If you specify centos instead of centos:centos7, you will get centos5, centos6, centos7 and latest (equals to centos7) images. Be prepared to allow 2GB of free disk space.
To display the list of locally available images, type:
# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos centos7 ae0c2d0bdc10 2 weeks ago 224 MB
Note: To remove this image, type # docker rmi ae0c2d0bdc10 or # docker rmi centos:centos7.
To test your new image, type:
# docker run centos:centos7 /bin/ping google.com -c 2 PING google.com (188.8.131.52) 56(84) bytes of data. 64 bytes from par10s10-in-f8.1e100.net (184.108.40.206): icmp_seq=1 ttl=54 time=12.5 ms 64 bytes from par10s10-in-f8.1e100.net (220.127.116.11): icmp_seq=2 ttl=54 time=12.6 ms
We are going to create a container (here called python_web) running a web server in Python on the 8000 port (/bin/python -m SimpleHTTPServer 8000).
This example is taken from a Red Hat article about Docker.
# mkdir -p /var/www/html # echo "Server up and running" > /var/www/html/test.txt # restorecon -R /var/www # docker run -d -p 8000:8000 --name="python_web" -v /usr/sbin:/usr/sbin -v /usr/bin:/usr/bin \ -v /usr/lib64:/usr/lib64 -w /var/www/html -v /var/www/html:/var/www/html centos:centos7 \ /bin/python -m SimpleHTTPServer 8000 # netstat -tupln | grep 8000 tcp6 0 0 :::8000 :::* LISTEN 27739/docker # curl localhost:8000/test.txt Server up and running
You can also:
- watch this Red Hat video giving a Docker overview (5min/2014),
- read this Red Hat article by Jeremy Eder about a Comprehensive Overview of Storage Scalability in Docker,
- read this nice presentation from Red Hat Etsuji Nakai about Linux Container Technology inside Docker with RHEL 7 (2015),
- read this Red Hat article about Docker Formatted Container Images on Red Hat Systems,
- read this presentation by Docker Jerome Petazzoni about Docker Storage Drivers,
- watch this presentation by Red Hat Chris Negus about Linux Containers Overview (20min/2015).,
- read this Red Hat article about the History of Containers,
- read this short tutorial if you want to start a docker container at boot time as a linux service,
- read this Tecmint tutorial about Installing Docker and Learning Basic Container Manipulations,
- read this article about why you shouldn’t use devmapper with Docker or this one about Running Docker on Loopback in Production,
- read this good tutorial about Docker for beginners,
- read this DigitalOcean tutorial about Installing and Using Docker,
- read this page about Some tools for working with Docker images,
- read this article by Dan Walsh about the way the Atomic Project deals with Docker patches,
- read this other article by Dan Walsh about Running systemd in a non-privileged container,
- read this article by Jeremy Eder about Getting overlay2 speed and density with devicemapper in Docker.