Solve the problem of starting two different ports when docker run

  • 2021-09-12 02:39:02
  • OfStack

Problem description:

After docker run-p 19918: 19918/tcp-v/etc/localtime:/etc/localtime

docker ps View has boot 19918 and another port, and no executors found in the registry.

Problem analysis:

The other port started is the previously configured container that was executed outside the project that just executed build when run was guessed.

Solution:

docker images Look at the container and delete the same and two executed port containers. Execute again and show success!

Summary:

Naming convention, clear unnecessary containers in time.

Additional knowledge: docker runs several different processes when it is started, installs ssh, and starts docker at the same time as jenkins when it is started

Recently, when doing jenkins slave node, it is necessary to install ssh to establish a link with master. At this time, slave needs to install ssh service, but after the node is restarted, ssh is started manually.

To avoid trouble, run ssh and jenkins services when you want to start up

1. When docker is running, starting ssh requires root permission, otherwise running sshd has no permission for many things

So when docker run, add a parameter-user root

docker run -d --user root --name jenkins_nodes3 --add-host gitlab.com:100.20.20.100 -v /home/_data_slave:/var/jenkins_home -p 8188:8080 -p 51005:50000 -p 8122:22 jenkins_ssh

2. Modify the/usr/local/bin/jenkins. sh startup file to add the following line

/usr/sbin/sshd -D > null 2 > & 1 &

If you are your own program, you can redirect the log to your own log file


Related articles: