1. Use Febootstrap to make base image
make a mirrored directoryIn Docker Getting Started (http://blog.csdn.net/woshiluahuo/article/details/51838451), we talked about base image, and now we're going to use the Febootstrap tool to make base Image
febootstrap-i bash-i wget-i yum-i iputils-i iproute-i man-i vim-i openssh-server-i openssh-clients-i t Ar-igzip Centos7 centos7-image http://mirrors.aliyun.com/centos/7/os/x86_64/ -I indicates the package that needs to be installed, such as the above statement: you want to install in base image: Bash, wget, yum, Iputils, Iproute, man, Vim, Openssh-server, Openssh-clients, TAR, gzip
This can be installed according to their own needs, where openssh-server, openssh-clients 2 packets are for the back SSH login preparation. 2. CENTOS7 is the operating system version centos7-image is the directory (base image wants to place in the server location)
4. Source address, I choose Aliyun, or I can use the other source address to execute the above statement will generate the Centos7-image file directory, contains the following files: The root directory is empty, if the mirror produced by using SSH login, will go directly to the root directory, and the general image is into the root directory, so execute: CD centos6-image && CP etc/skel/.bash* root/Statement, will. Bash_logout bash_profile. BASHRC, these three Copy files to the root folder.
Generate base ImageExecutive: CD centos7-image && tar-c. | Docker the Import-centos7-base statement, packages the contents of the Centos7-image directory and creates the packaged content as a Docker mirror. Look at the mirror and discover that there is a mirror in the mirror named: Centos7-base We can now run the centos7-base mirror in the container of Docker.
2. Use Dockfile to make an image with SSH login
DockfileWith the centos7-base we just made as base image, use Dockfile to make an image that uses SSH logins. Create
name is: Dockfilefile, which reads as follows: #Dockerfile from Centos7-base #将centos7-base as base image, similar to the concept of inheritance, the new image produced has the function of base image maintainer Ahuo Run Ssh-keygen-q-N ""-t dsa-f/etc/ssh/ssh_host_dsa_key RUN ssh-keygen-q-N ""-T rsa-f/etc/ssh/ssh_host_rsh_key R UN Sed-ri ' s/session required pam_loginuid.so/#session required pam_loginuid.so/g '/etc/pam.d/sshd RUN mkdi R-p/root/.ssh && chown root.root/root && chmod 700/root/.ssh #上面几行都是配置ssh登录目录和登录验证的, while SSH is installed in base imag E centos7-base (-i openssh-server-i openssh-client) expose #开端口 RUN echo ' Root:redhat ' | CHPASSWD #重置root密码为redhat RUN yum Install tar gzip gcc vim wget-y ENV LANG en_US. UTF-8 ENV lc_all en_US. UTF-8 cmd/usr/sbin/sshd-d #End in the Centos7-image directory, execute the build command, CENTOS7-SSH is the generated image name, followed by the Dockfile directory. At this point, we can see that image has a centos7-ssh mirror image.
Verifying SSH logon1. Docker run-d Centos-ssh:latest/bin/bash runs the centos-ssh mirror to generate a container,-D indicates that it runs in the background. 2. At this point, you can see the starting container using the Docker ps-a command. 3. Use the Docker inspect CONTAINER ID to view the container's information to find IP address 4. Use the SSH root@172.17.0.2 login container, the password is modified in Dockfile with other features of the image is also Method of production, validation.
3. Make the mirror quickly with the container to better understand and use Docker mirrors, containers, and decide to install Oracle with base image, the packaged container is made as an oracle mirror. The benefits of using a container for mirroring are: the first is to step in step. When you make a mirror that is more complex, it is impossible to succeed in one step, so when you think that the next step may be an error (irreversible error), you can first pack the mirror, if the next mistake, delete the container, and then the package of the mirror just wrapped to do a container, continue the previous steps. the second is that no matter how you toss in the container it doesn't matter, big deal to remove this container, if you are on the physical server to pay considerable attention, otherwise duang, The entire server is paralyzed. The third benefit is similar to the first one, because some databases cannot be tested, and you will produce very large data (logs, and some default data) for a test (when I do mongodb mirroring, After the test of the package after the mirror has reached 4 G, and did not test on the hundreds of MB, the difference is too large, because the Docker mirror can not be too large, otherwise bad upload. So it is generally done, first pack into a mirror, and then test, if successful. That's OK. Ideal is very full, showing a backbone, in the installation of Oracle process, the error. This error is due to hostname requirements for Oracle installations, which require hostname to contain numbers, but Docker automatically assigns an ID to the container in the process of running mirroring as a container. This ID is made up of numbers and letters. Can not use the general modification of the hostname to modify the container hostname, see the Internet has to use the Docker-compose tool to modify the container hostname, I did not try (well, because lazy, if you try to update). Ps:docker Run-add-host This is not a modification hostname ~ Although the container is not successfully used to make Oracle mirrors, the statement that uses the container to make mirrors is theoretically: docker COMMIT  XXX (container ID) xxxx (image name to be made) finally use Docker search Oracle to find the next Oracle Mirror, then docker pull docker.io/wnameless/oracle-xe-11g, when the download is complete, you can see that a oracle-xe-11g mirror is added to the mirror list. Running the mirror as a container, after entering the container, su-oracle switches to the Oracle user, can see the Oracle installation directory, can run the Sqlplus/as sysdba command into the database.
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.