Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install docker

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to install docker, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Operating system: centos 6.5

1. Install: 1. Configure Epel source: yum install-y yum-priorities & & rpm- ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm & & rpm--import / etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-62, install docker-io febootstrap

# tools used by febootstrap to create centos images

Yum install docker-io febootstrap-y3. Hang cgroup file system vim / etc/fstab after installation: add a line: none / sys/fs/cgroup cgroup defaults 004, restart the system: reboot

Docker starts automatically after booting. If it doesn't start, you can start it manually: docker-d &

2. Let's make a Centos 6.5. create a CentOS image file using febootstrap. Centos6-image directory febootstrap-I bash-I wget-I yum-I iputils-I iproute-I man-I vim-I openssh-server-I openssh-clients-I tar-I gzip centos6 centos6-image http://mirrors.aliyun.com/centos/6/os/x86_64/

# Parameter description:

The tools that need to be installed in the-I image: pass the parameters after-I to yum to implement the installation, on which the ssh service is installed

Centos6 is the centos version

Centos6-image is the specified directory

After the command is executed, a directory centos6-image is generated under the current directory

Bash-4.1.2#bash-4.1.2#bash-4.1.2# ls bin boot dev etc home lib lib64 media mnt opt proc root sbin selinux srv sys tmp usr varbash-4.1.2# ls-a root

There are no files or hidden dot files in the root directory, such as .bash _ logout .bash _ profile .bashrc.

If the image created at this time uses ssh to log in, it will go directly to the root directory, as follows:

Bash-4.1.2#bash-4.1.2#bash-4.1.2# ls bin boot dev etc home lib lib64 media mnt opt proc root sbin selinux srv sys tmp usr varbash-4.1.2# ls-a root. ..

To avoid this, you can set the .bash _ logout .bash _ profile .bashrc files in the root directory of the centos6-image directory.

Cd centos6-image & & cp etc/skel/.bash* root/

In this way, the remote login can be realized normally.

Based on this implementation, we can configure some complex configuration files in advance and put them in a directory, and then call them through the Dockerfile file, which can be completed quickly.

2. Let's create a basic image cd centos6-image & & tar-c. | docker import-centos6-base

When the command is complete, use docker images to view

Docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEcentos6-base latest a01c3d440db8 1 minutes ago 311.3 MB

At this point, a basic mirror has been completed.

3. Let's use the Dockerfile file to create an image that can be logged in by ssh

The Dockefile file is as follows:

# DockerfileFROM centos6-baseMAINTAINER zhou_mfk RUN ssh-keygen-Q-N ""-t dsa-f / etc/ssh/ssh_host_dsa_keyRUN ssh-keygen-Q-N ""-t rsa-f / etc/ssh/ssh_host_rsa_keyRUN sed-ri 's/session required pam_loginuid.so/#session required pam_loginuid.so/g' / etc/pam.d/sshdRUN mkdir-p / root/.ssh & & chown root.root / root & & chmod 700 / root/.sshEXPOSE 22RUN echo 'root:redhat' | chpasswdRUN yum install-y yum-priorities & & rpm- ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm & & rpm--import / etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6RUN yum install tar gzip gcc vim wget-yENV LANG en_US.UTF-8ENV LC_ALL en_US.UTF-8CMD / usr/sbin/sshd-D#End

For instructions on Dockerfile, please see Docker series related blog posts and Dockerfile files for details.

4. Use the above Dockerfile file to create a ssh login image docker build-t centos6-ssh.

Build: Build a container from a Dockerfile this is to create a container from the Dockerfile file

Docker build looks for a configuration file named Dockerfile under the path path, and uses this configuration to generate a new image

. Indicates that in the current directory

Docker build-t centos6-ssh / root/images/abc this means that the Dockerfile file is under: / root/images/abc

After the command is executed, the centos6-ssh image is created.

Check it out:

Docker images

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

Centos6-ssh latest b8ca70e7adee 1 hours ago 311.3 MB

Centos6-base latest a01c3d440db8 2 hours ago 311.3 MB

Let's create a container to log in:

Docker run-d-p 127.0.0.1 2222 22 centos6-ssh

Ssh root@127.0.0.1-p 2222

Enter password: redhat

[root@a856a3c242cf ~] #

[root@a856a3c242cf ~] #

[root@a856a3c242cf ~] # ls

[root@a856a3c242cf ~] #

[root@a856a3c242cf ~] # cat / etc/issue

CentOS release 6.5 (Final)

Kernel\ r on an\ m

Thank you for reading this article carefully. I hope the article "how to install docker" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report