Deploy and maintain Docker environments

Source: Internet
Author: User
Tags epel repo orientdb percona ssh access docker ps docker run haproxy etcd

In fact, the previous use of salt, installation and deployment of Docker application environment, the process has encountered a lot of problems, so here again relatively careful record, Docker mobile phone installation process should pay attention to the installation process section refer to the Liu Tians master document Deployment

1, Installation Environment description

系统环境:centos6.6服务应用了:  haproxy  confd   etcd   docker主机名               ip      服务角色dockerha-152      192.168.36.152    haproxy confddockerEtcd-153     192.168.36.153      etcddockermain-154    192.168.36.154    docker

2, install according to lazy packet, close the conflict service

官方文档要求Linux kernel至少3.8以上,且docker只能运行在64位的系统中。由于RHEL6和CentOS6的内核版本为2.6,因此必须要先升级内核。cd /etc/yum.repos.d wget http://www.hop5.in/yum/el6/hop5.repoyum install kernel-ml-aufs kernel-ml-aufs-devel -y修改grub的主配置文件/etc/grub.conf,设置default=0,表示第一个title下的内容为默认启动的kernel(一般新安装的内核在第一个位置)。然后重启,重启系统,这时候你的内核就成功升级了,版本应该在3.8以上了,uname -r [[email protected] shell]# uname -r3.10.5-3.el6.x86_64sed -i ‘/^SELINUX=/c\SELINUX=disabled‘ /etc/selinux/configsetenforce 0在Fedora EPEL源中已经提供了docker-io包,下载安装epel:rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm sed -i ‘s/^mirrorlist=https/mirrorlist=http/‘ /etc/yum.repos.d/epel.repo

3, installing the components

(1) Haproxy CONFD

Operation on dockerha-152

1、haproxy  # yum –y install haproxy  2、confd  # wget https://github.com/kelseyhightower/confd/releases/download/v0.6.3/confd-0.6.3-linux-amd64  # mv confd /usr/local/bin/confd  # chmod +x /usr/local/bin/confd  # /usr/local/bin/confd -version 

(2) Etcd

Operation on dockerEtcd-153

# mkdir -p /home/install && cd /home/install  # wget https://github.com/coreos/etcd/releases/download/v0.4.6/etcd-v0.4.6-linux-amd64.tar.gz  # tar -zxvf etcd-v0.4.6-linux-amd64.tar.gz  # cd etcd-v0.4.6-linux-amd64  # cp etcd* /bin/ # /bin/etcd -version etcd version 0.4.6 

(3) Docker

# yum -y install docker-io  # service docker start  # chkconfig docker on  

The 4,docker command uses

(1) View Help

docker COMMAND --help

(2) Search for available landscape images

Docker Search Name as an example:[Email protected] src]# Docker Search Centosname DESCRIPTION STARS offici AL Automatedcentos The official build of CentOS.817[OK] Ansible/centos7-ansible ansible on Centos730[OK]tutum/centos CentOS image with SSH access. For the root ...13[OK]jdeathe/centos-ssh-apache-php CentOS-6 6.5 x86_64/apache/php/php m ...8[OK]blalor/centos Bare-bones Base CentOS 6.5 image8[OK]jprjr/centos-php-fpm6[OK]steeef/graphite-centos CentOS 6.x with graphite and Carbon via ng ...6[OK]tutum/centos-6.4 DEPRECATED. Use tutum/centos:6.4 instead. ...5[OK]layerworx/centos A General CentOS6 image with the EPEL6 ...2[OK]jr42/chef-solo-centos official CentOS base images with current C ...1[OK]million12/centos-supervisor Base CentOS-7 with Supervisord launcher, h ...1[OK]internavenue/centos-percona centos-based Percona image.1[OK]jdeathe/centos-ssh CentOS-6 6.5 X86_64/epel Repo. /OpenSSH ...1[OK]jdeathe/centos-ssh-mysql CentOS-6 6.5 x86_64/mysql. Image include ...1[OK]yajo/centos-epel CentOS with Epel and fully updated1[OK]nimmis/java-centos This is Docker images of CentOS7 with dif ...0[OK]lighthopper/orientdb-centos A DockerfileFor creating an Orientdb imag ...0[OK]bbrietzke/centos-starter CentOS7 with EPEL and Supervisord0[OK]tcnksm/centos-node Dockerfilefor CentOS packaging node 0 [ok]insaneworks/centos CentOS 6.5 x86_64 + @update 0 [ok]snowyday/centos provide for Emacs and Ricty font on X11 en ... 0 [ok]dmglab/centos CentOS with superpowers! 0 [ok]akroh/centos centos 6 container that have been Updated W ... 0 [ok]timhughes/centos CentOS with SYSTEMD installed and running 0 [ok]solict/provisionous-puppet-centos CentOS provisions with puppet Included 0 [ok]         

(3) Download image

Note that the name of the image is written in full, which is the name that is searched for by the Docker search name.

docker pull name 如示例:[[email protected] src]# docker pull jdeathe/centos-ssh-apache-phpPulling repository jdeathe/centos-ssh-apache-php........62203f428b1f: Download complete e1812755a4ca: Download complete 0910edda3736: Download complete Status: Downloaded newer image for jdeathe/centos-ssh-apache-php:latest

(4) View installed images

[[email protected] src]# docker imagesREPOSITORY                      TAG                 IMAGE ID            CREATED             VIRTUAL SIZEcentos                          latest              dade6cb4530a        10 days ago         210.1 MBjdeathe/centos-ssh-apache-php   latest              f1a489312a4a        3 months ago 297.7 MB

(5) Run command in Docker container

docker run命令有两个参数,一个是镜像名,一个是要在镜像中运行的命令。 注意:IMAGE=REPOSITORY[:TAG],如果IMAGE参数不指定镜像的TAG,默认TAG为latest。[[email protected] run]# sudo docker run jdeathe/centos-ssh-apache-php echo ‘hello world!‘hello world![[email protected] run]# sudo docker run jdeathe/centos-ssh-apache-php hostnamedb7e1d2269fb

(6) List containers

[[email protected] run]# docker ps -lCONTAINER ID        IMAGE                                  COMMAND             CREATED             STATUS                      PORTS               NAMESdb7e1d2269fb        jdeathe/centos-ssh-apache-php:latest   "hostname"          27 seconds ago Exited (0) 26 seconds ago adoring_babbage 

(7) Display container standard output

[[email protected] run]# docker ps -lCONTAINER ID        IMAGE                                  COMMAND             CREATED             STATUS                      PORTS               NAMESdb7e1d2269fb        jdeathe/centos-ssh-apache-php:latest   "hostname"          27 seconds ago Exited (0) 26 seconds ago adoring_babbage [[email protected] run]# docker logs db7e1d2269fbdb7e1d2269fb

(8) Install the program or service to the container

[[email protected] run]# sudo docker run centos yum install -y httpdLoaded plugins: fastestmirror..........Dependency Installed:  apr.x86_64 0:1.4.8-3.el7                                                        apr-util.x86_64 0:1.5.2-6.el7                                                   centos-logos.noarch 0:70.0.6-1.el7.centos                                       httpd-tools.x86_64 0:2.4.6-19.el7.centos                                        mailcap.noarch 0:2.1.41-2.el7                                                 Failed:  httpd.x86_64 0:2.4.6-19.el7.centos                                            Complete!

(9) Save changes to the container and generate a new image

[REPOSITORY[:TAG]]REPOSITORY参数可以是新的镜像名字,也可以是旧的镜像名;如果和旧的镜像名和TAG都相同,会覆盖掉旧的镜像。[[email protected] ~]# docker commit bd7cc4f4ac92 centos:httpd1e0915f3247b86414ebc11fd994fc6abfb590ff3b1ab890949c845ee88b2d9f4[[email protected] ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEcentos httpd 1e0915f3247b 9 seconds ago 320.8 MBcentos latest dade6cb4530a 10 days ago 210.1 MBjdeathe/centos-ssh-apache-php latest f1a489312a4a 3 months ago 297.7 MB

(10) Stop a running container

(11) View container or mirror details

Here is the new container I just saved the submission from[[Email protected] ~]# Docker Inspect 943E45B6E5F3[{"Apparmorprofile":"","Args":[],"Config":{"Attachstderr":True"Attachstdin":True"Attachstdout":True"CMD":["/bin/bash"],"Cpushares": 0,"Cpuset":"","Domainname":"","entrypoint": null,"ENV":["Path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"], "exposedports": null, "Hostname": "943e45b6e5f3", "Image": "centos:httpd", "MacAddress ":" ", " Memory ": 0, " Memoryswap ": 0, " networkdisabled ": false, " Onbuild ": null, " Openstdin ": True, " portspecs ": null, " Stdinonce ": True, " Tty ": True, " User ":" " , "Volumes": null, "Workingdir": " " },         

(12) Remove container

$(docker ps -a -q)

(13) Delete image

docker rmi IMAGE

(14) View Docker information, including number of containers and images, kernel version, etc.

[[email protected] ~]# docker infoContainers: 14Images: 56Storage Driver: aufs Root Dir: /var/lib/docker/aufs Dirs: 89Execution Driver: native-0.2Kernel Version: 3.10.5-3.el6.x86_64Operating System: <unknown>CPUs: 1Total Memory: 989.6 MiBName: dockermain-154ID: W4PW:W3XR:FQZE:SBAA:2DS2:BM6N:DV5B:ARF2:3SZM:XGST:5ZF7:DFZVWARNING: No swap limit support

(15) Create the container and use it as usual SSH login

[[email protected] ~]# docker run -i -t centos /bin/bash[[email protected] /]# lsbin dev etc home lib lib64 lost+found media mnt opt proc root run sbin selinux srv sys tmp usr var

Deploy and maintain Docker environments

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.