Docker common operations

Source: Internet
Author: User
Tags exit redis centos docker ps docker run install redis

Dabby@ybbad


Vi/etc/ssh/sshd_config


Yum Install Net-tools-y


Etc/yum.repos.d/vim Docker.repo
(Download installation source)
——-
[Dockerrepo]
Name=docker
repositorybaseurl=https://yum.dockerproject.org/repo/experimental/centos/7/
Enabled=1
Gpgcheck=1
Gpgkey=https://yum.dockerproject.org/gpg


——-
Yum Install Bridge_utils-y (Assign Bridge tool)


IP A


BRCTL ADDBR ABC


IP addr Add 123.0.0.1/16 dev (set network segment)


IP link set dev ABC up (start Bridge)


/lib/systemd/system/docker.service


/user/bin/dokerd-b=abc


————————————————————————————————————————————————————————————-


Installing Docker:yum Install Docker-engine-y


Systemctl Restart Docker (start service)
Systemctl Enable Docker (boot up)


Docker Login Daocloud.io


Docker Pull daocloud.io/library/ubuntu:trusty-20150228.11


Docker images


Docker run
Exit
Exit


Docker Run-ti Daocloud.io/library/centos:6.8/bin/bash
Docker Run-ti Daocloud.io/library/ubuntu:trusty-20150228.11/bin/bash
(CLI command, launch Docker image)




Yum install-y nginx (Rpm-qa nginx)


Apt-get Install Nginx (dpkg-s nginx)


Docker run-ti-p 82:80 nginx:1028 Bash
(Start an nginx image)


Curl Http://mirrors.aliyun.com/repo/epel.repo-o/tmp/
(Download installation source)


Nginx
Start


Netstat-ntlap


CD nginx/


VI conf.d/default.conf


cd/usr/share/nginx/html/


VI Abc.txt


Docker Ps-a


CD ABC


VI Dockerfile


Docker build-t nginx2:10288-f Dockerfile.


Docker run-tl-p 81:80-v/home:/volume1/log nginx:1028 Bash


Docker run-d-P 83:80-v/home/log:/usr/share/nginx/html nginx2:10288


Docker Exec-ti b0afc4f7369b Bash


Docker Inspect daocloud.io/library/centos:6.8


Docker Network LS


Docker Network Create--help


Docker Network Connect--ip 123.0.0.100 Mybridge b0afc4f7369b




Docker Exec-ti b0afc4f7369b Bash










——————————————————————————————-
Yum-y Install Redis


Bind 127.0.0.1 192.168.1.45 Modify IP Port






Redis-server redis.conf START Process


Redis-cli-h 172.16.1.66 Connect the Redis client to other Redis


Redis-cli-h 172.16.1.66 Keys "history_orderinfo_*" |xargs redis-cli-h 172.16.1.66 del




Statistics: REDIS-CLI keys "history_*" |wc-l


Delete: Redis-cli keys "history_*" |xargs redis-cli del


















————————————————————————————————————————————————————————————————————————


————————————————————————————————————————————————————————————————————————




Docker images


Docker Pull Daocloud.io/library/ubuntu:latest


Initiates a virtual machine image in an interactive manner that can be manipulated directly by this image
Docker Run-ti Daocloud.io/library/ubuntu:latest/bin/bash



Running in the background
Docker run-d Daocloud.io/library/ubuntu:latest/sbin/init


Enter
Docker Exec-ti 7fae8f009efe Bash


(7fae8f009efe: Container ID that runs in the background)






Eixt
Docker Ps-a




To install Nginx in a container:
Apt-get Update


Apt-get Install Nginx








Second Image:


Docker Pull Daocloud.io/library/nginx:latest
——————-


1, Dockerfile:


wget http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz


2. New Docker Source


Vim Dockerfile


From Daocloud.io/library/ubuntu:latest
Env Timedate 2017-05-24


3. Copy the JDK package into the mirror


From Daocloud.io/library/ubuntu:latest
Env Timedate 2017-05-24
Add Jdk1.8.0_131/home
Env java_home/home/jdk1.8.0_131
Env PATH $PATH: $JAVA _home/bin: $JAVA _home/db/bin: $JAVA _home/jre/bin




(The jdk1.8.0_131 folder overwrites the home directory in the image, where the tar package is cached to solve the problem)




4. Build Dockerfile




Docker build-t java8:first-f Dockerfile.








5, the implementation of the image;


Docker run-d-P 80:8080-p 2222:22 java8:first/sbin/init


(-P 80:8,080): 80 external network, 8080ubuan port
(-P 2,222:22): 2222 external network, 22 container 22 remote port


Docker PS




6. Enter the Mirror (interactive environment)




Docker Exec-ti 7fae8f009efe/bin/bash




7FAE8F009EFE (Mirror ID)




7. Delete container, mirror




Stop the container first, then delete the container, and finally remove the mirror














《《《《《《《《《《《《《《《


Dragon
1.


From Daocloud.io/library/ubuntu:latest
Env Timedate 2017-05-24
Add jdk-8u131-linux-x64.tar.gz/home/
Add apache-maven-3.3.9-bin.tar.gz/home/
Add apache-tomcat-8.5.15.tar.gz/home/
Run Apt-get Update
Run Apt-get Install Nginx-y


Env java_home/home/jdk1.8.0_131
Env maven_home/home/apache-maven-3.3.9
Env PATH $PATH: $JAVA _home/bin: $JAVA _home/db/bin: $JAVA _home/jre/bin: $MAVEN _home/bin




2, Docker build-t java8:stable-f dockerfile.


3, Docker run-d-P 81:8080-p 222:22 java8:first/sbin/init (not applicable)




Docker run-d-P 81:8080-v/share:/share java8:stable/sbin/init (logical volume mapped to host)

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.