In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
What this article shares with you is about how to build an automatic deployment docker environment from scratch. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.
Start from 0 to build an automatic deployment environment
After changing the use of dynamic libraries from Docker, DooD is no longer feasible, while Dind is still feasible. In response to this change, reorganize and record the automatic deployment environment configuration steps.
This environment is the basis for automatic deployment of micro-services, using jenkins continuous integration tools, built-in java and maven, and the function of running Docker commands in the container.
Software environment
Host win10
Virtual machine CentOS-7-x86_64-Minimal-1708
Docker 17.09.0-ce
Apache-maven-3.5.2
Jdk 1.8.0_151
Jenkins 2.73.3
Virtual machine installation configuration 1. Install Docker
Refer to the official tutorial Get Docker CE for CentOS option: change the source. The official source may be slow to download Docker and replace it with a domestic Docker source, such as Aliyun's Docker source https://download.docker.com/linux/centos/docker-ce.repo
two。 Start Docker and set Boot $sudo service docker start$ sudo chkconfig docker on3. Replace the Docker mirror source
Downloading the image from the official source of Docker may be slow, just replace it with the source of Aliyun. Aliyun exclusive accelerator address. Copy the tutorial for easy reference.
Install / upgrade your Docker client
It is recommended to install the Docker client above version 1.10.0. Refer to the documentation docker-ce.
How to configure Mirror Accelerator for users whose Docker client version is greater than 1.10.0
You can use the accelerator by modifying the daemon configuration file / etc/docker/daemon.json:
Sudo mkdir-p / etc/dockersudo tee / etc/docker/daemon.json / etc/sudoers\ & & gpasswd-a jenkins docker\ & & echo "root:root" | chpasswdENV JAVA_HOME/ usr/lib/jvm/javaENV PATH $JAVA_HOME/bin:$PATHENV MAVEN_HOME/ opt/apache-maven-3.5.2ENV PATH $MAVEN_HOME/bin:$PATHENV TZ=Asia/ShanghaiRUN ln-snf / usr/share/zoneinfo/$TZ / etc/localtime & & echo $TZ > / etc/timezone# add aliyun maven mirror sourceRUN sed-I' / / I\ nnexus-aliyun\ ncentral\ n Nexus aliyun\ nhttp://maven.aliyun.com/nexus/content/groups/public\n' / opt/apache-maven-3.5.2/conf/settings.xmlUSER jenkinsCMD sudo service jenkins start & & tail-F / var/log/jenkins/jenkins.log2. Compile Dockerfiledocker build-t jeesun/java-jenkins. 3. Launch container docker run-- privileged-I-t-v / var/run/docker.sock:/var/run/docker.sock-p 808080 jeesun/java-jenkins
At this point, I have logged in to the container using my jenkins account, and according to Dockerfile, jenkins has started itself and is currently running the command tail-F / var/log/jenkins/jenkins.log.
Press Ctrl+P+Q to exit bash. The command Ctrl+P+Q ensures that the exit container does not close the container.
Visit http://localhost:8080. Of course, because I installed the minimal version of CentOS, there is no graphical interface, can only be accessed on the host through the http:// virtual machine ip:8080. You can use the command ip addr to view the virtual machine ip address.
Use docker ps to view the CONTAINER ID.
Use docker exec-it container_id / bin/bash to enter the container.
The first access to this address requires the initial administrator password in / var/lib/jenkins/secrets/initialAdminPassword to unlock the jenkins. Execute cat / var/lib/jenkins/secrets/initialAdminPassword to know the password.
Follow the instructions on the page and jenkins will recommend downloading some plug-ins. I installed it by default. If the installation fails, try again. Then fill in the new administrator account password. After completion, officially enter the jenkins management page.
5. test
Select New, fill in the project name, and choose to build a free-style software project. Build-"add build steps--" Execute shell-- "fill in docker run hello-world--" to save. Choose to build now. If you do not report an error, the balloon is blue, indicating success.
6. Automatic deployment
Build an automated deployment environment from 0 (continued)
Report an error and solve 1. Error 1 error content Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.34/version: dial unix / var/run/docker.sock: connect: permission denied solution
Give priority to the official Manage Docker as a non-root user.
Turn off the selinux of the virtual machine (which may be useful). Refer to check the status of SELinux and close SELinux.
Modify the permissions of / var/run/docker.sock in the virtual machine. It's dangerous! )
$sudo chmod 777 / var/run/docker.sock2. Error 2 error content Failed to get D-Bus connection: Operation not permitted solution
ignore.
3. Error 3 error content Couldn't connect to Docker daemon at http+unix://var/run/docker.sock-is it running? Solution
Permission issue. The solution is the same as error 1.
The above is how to build an automatic deployment docker environment from scratch. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.