持续集成 求解救:使用 docker 启动 jenkins 遇到的问题。

渐渐 · 2020年07月16日 · 最后由 渐渐 回复于 2020年07月17日 · 6142 次阅读

执行命令:

sudo docker run --name qiuqiujenkins -p 8080:8080 -p 50000:50000 docker.io/jenkins/jenkins

如下报错 1,尝试了各种网上搜索,百度谷歌,也查了,并没有什么地方端口占用了,不知道是不是因为自己找的宿主机的没有占用,是不是 docker 里的 50000 端口被占用了?在解决过程中,又尝试了几次,没有了报错 1 ,但是又来了报错 2,简直绝望~~

# 报错1
/usr/bin/docker-current: Error response from daemon: driver failed programming external connectivity on endpoint qiuqiujenkins (1c1a7148ea2078f9db5c74cc9b2ec720506c046dbdfb62429b2a227a7ef1de98): Bind for 0.0.0.0:50000 failed: port is already allocated.
ERRO[0000] error getting events from daemon: net/http: request canceled
# 报错2
/usr/bin/docker-current: Error response from daemon: failed to update store for object type *libnetwork.endpointCnt: Key not found in store.
ERRO[0000] error getting events from daemon: net/http: request canceled

后续尝试重启 docker

▶ sudo service docker start
Redirecting to /bin/systemctl start docker.service
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

▶ systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 四 2020-07-16 18:54:33 CST; 15s ago
     Docs: http://docs.docker.com
  Process: 755 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
 Main PID: 755 (code=exited, status=1/FAILURE)

▶ sudo journalctl -xe
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit user-0.slice has finished shutting down.
7月 16 18:54:33 localhost.localdomain sudo[686]:  jfj0289 : TTY=pts/0 ; PWD=/home/jfj0289 ; USER=root ; COMMAND=/sbin/service docker start
7月 16 18:54:33 localhost.localdomain sudo[686]: pam_unix(sudo:session): session opened for user root by jfj0289(uid=0)
7月 16 18:54:33 localhost.localdomain polkitd[1008]: Registered Authentication Agent for unix-process:688:305794921 (system bus name :1.2081 [/usr/bin/pkttyagent
7月 16 18:54:33 localhost.localdomain systemd[1]: Starting Docker Storage Setup...
-- Subject: Unit docker-storage-setup.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker-storage-setup.service has begun starting up.
7月 16 18:54:33 localhost.localdomain systemd[1]: Started Docker Storage Setup.
-- Subject: Unit docker-storage-setup.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker-storage-setup.service has finished starting up.
--
-- The start-up result is done.
7月 16 18:54:33 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
-- Subject: Unit docker.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has begun starting up.
7月 16 18:54:33 localhost.localdomain dockerd-current[755]: Error starting daemon: pid file found, ensure docker is not running or delete /var/run/docker.pid
7月 16 18:54:33 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
7月 16 18:54:33 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is failed.
7月 16 18:54:33 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
7月 16 18:54:33 localhost.localdomain systemd[1]: docker.service failed.
7月 16 18:54:33 localhost.localdomain polkitd[1008]: Unregistered Authentication Agent for unix-process:688:305794921 (system bus name :1.2081, object path /org/f
7月 16 18:54:33 localhost.localdomain sudo[686]: pam_unix(sudo:session): session closed for user root
7月 16 18:55:40 localhost.localdomain sudo[822]:  jfj0289 : TTY=pts/0 ; PWD=/home/jfj0289 ; USER=root ; COMMAND=/bin/journalctl -xe
7月 16 18:55:40 localhost.localdomain sudo[822]: pam_unix(sudo:session): session opened for user root by jfj0289(uid=0)
lines 2731-2773/2773 (END)
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 1 条回复 时间 点赞

问题已解决,说下我的心路历程,希望对其他同学有所帮助,并且感谢@466895041

  1. docker-Jenkins 启动失败
  2. 简化,服务器后台 nohup 直接启动 Jenkins,还是启动失败
  3. 再简化,服务器命令行当前进程直接启动 Jenkins,启动失败
  4. 排查问题:java 环境问题、文件权限、jenkins 的启动用户、端口问题,发现端口 8080 被占用,切换为 8081,还是无法访问;
  5. 因为已经提示 Jenkins fully up,所以觉得就是端口问题,继续查 jenkins 端口关键字,搜到以下答案:

https://testerhome.com/topics/19457中的最佳答案

1,查下端口是否开放: firewall-cmd --query-port=8888/tcp yes为开放,no为未开放
2,如果为no,可以添加端口为开放状态:firewall-cmd --add-port=8888/tcp --permanent 再重载 firewall-cmd --reload
3,再查下下端口是否开放
4,如果没效,直接关防火墙 systemctl stop firewalld

执行完前三步,成功通过web访问到jenkins
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册