docker (consul and Jenkins)

consul

# Pull
docker pull consul 
# start up
docker run -d -p 8500:8500-v /usr/local/docker/consul:/consul/data -e CONSUL\_BIND\_INTERFACE='eth0'--name=cxyConsul mirror id agent-server -bootstrap -ui -node=node-1-client='0.0.0.0'-datacenter=cxy

server: Start as server. The default is client
bootstrap-expect: The minimum number of servers required by the cluster. When it is lower than this number, the cluster fails.
data-dir: The directory where data is stored. For more information, please refer to the consul data synchronization mechanism
node: node id, each node in the cluster must have a unique name. By default, Consul uses the hostname of the machine
bind: listening ip address. Default binding 0.0.0.0, can not be specified. Indicates the address monitored by Consul,And it must be accessible by other nodes in the cluster. Consul will listen to the first private IP by default,But it is better to provide one. The server on the production equipment usually has several network cards, so it is not wrong to specify one
client:The ip address of the client, 0.0.0.0 means anyone can visit (do not add this, the following ui:8500 cannot be accessed)
ui:Can access the UI interface
- config-dir specifies the configuration folder, Consul will load all files in it
- datacenter specifies the name of the data center, the default is dc1

Jenkins

Judging by the Mirror OFFICIAL label, the one with the name jenkins ranked first is the official Jenkins mirror. Should we use this official mirror?

If you have read the Docker installation section in the Jenkins documentation, you will find that the official recommended image is jenkinsci/blueocean, which contains the current long-term support (LTS) version of Jenkins (which can be used in production) and bundles all Blue Ocean plugins and Features.

The Jenkins image was used for the first installation. The integrated Jenkins version was relatively high. As a result, a lot of plug-in incompatibility appeared. It was a troublesome thing for me and other Xiaobai.

Here we decisively use the jenkinsci/blueocean image and use the docker pull command to pull:

# Pull mirror
docker pull jenkinsci/blueocean
# Start the container
docker run \
 - - name cxyJenkins-blueocean \
 - d \
 - p 8081:8080 \
 - p 50000:50000 \
 - v /usr/local/docker/jenkins:/var/jenkins_home \
 jenkinsci/blueocean
 # Report an error
 [ root@centos8 jenkins]# docker logs 06a6e888dbf5
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
# modify
sudo chown -R 1000:1000/usr/local/docker/jenkins
# success
root@centos8 jenkins]# sudo chown -R 1000:1000/usr/local/docker/jenkins
[ root@centos8 jenkins]# docker start 06a6e888dbf5
06 a6e888dbf5
[ root@centos8 jenkins]# docker ps 
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                                  NAMES
06 a6e888dbf5        jenkinsci/blueocean   "/sbin/tini -- /usr/…"4 minutes ago       Up 3 seconds        0.0.0.0:50000->50000/tcp,0.0.0.0:8081->8080/tcp       cxyJenkins-blueocean
63785 bef8658        6ad6cb039dfa          "/docker-entrypoint.…"2 weeks ago         Up 10 minutes       2888/tcp,3888/tcp,0.0.0.0:2181->2181/tcp,8080/tcp   cxyZookeeper
992 d0be96bc1        mysql:8.0.20"docker-entrypoint.s…"5 weeks ago         Up 10 minutes       33060/tcp,0.0.0.0:3307->3306/tcp                      mysqlSlave
23 ceac64fab5        mysql:8.0.20"docker-entrypoint.s…"5 weeks ago         Up 10 minutes       0.0.0.0:3306->3306/tcp,33060/tcp                      mysqlMaster
48 f8725736c3        redis:6.0.5"docker-entrypoint.s…"5 weeks ago         Up 10 minutes       6379/tcp,0.0.0.0:7003->7003/tcp                       redisSentinel
38 c2f6e00354        redis:6.0.5"docker-entrypoint.s…"5 weeks ago         Up 10 minutes       6379/tcp,0.0.0.0:6666->6666/tcp                       cxyredis
# If everything is normal to access the above, you can now use http://<ipaddress>:8081 Visited the Jenkins web interface.
# Administrator initialization password
[ root@centos8 jenkins]# docker exec -it 06a6e888dbf5 /bin/bash
bash-5.0$ cat /var/jenkins_home/secrets/initialAdminPassword
c994db795bb9450399b48e54efbc1b47

Recommended Posts

docker (consul and Jenkins)
Centos7 installation and configuration of Jenkins
Install and configure Docker in Ubuntu
Install and use docker under CentOS 6.8
ubuntu Docker installation and deployment of Rancher
Install docker on ubuntu and basic usage
n1. Docker installation and operation exceptions encountered
Deploy Docker and configure Nginx in CentOS
Jenkins installation and deployment tutorial under CentOS 7
Linux install Docker and run Ubuntu system