RHEL7: How to get started with Docker.

Share this link

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.

Installation

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 (173.194.40.136) 56(84) bytes of data.
64 bytes from par10s10-in-f8.1e100.net (173.194.40.136): icmp_seq=1 ttl=54 time=12.5 ms
64 bytes from par10s10-in-f8.1e100.net (173.194.40.136): icmp_seq=2 ttl=54 time=12.6 ms

Container Creation

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

Sources: Docker web site and Red Hat’s article about Docker.

Additional Resources

You can also:

(2 votes, average: 5.00 out of 5)
Loading...

Leave a Reply

Upcoming Events (Local Time)

There are no events.

Follow me on Twitter

Archives

vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |