docker pull 不通?必须解决, 立刻马上,忍不了一点,没废话,直接用
记得好评, 嘿嘿
出现的问题
consola@admin:~$ sudo docker pull mysql
Using default tag: latest
Error response from daemon: Get “https://registry-1.docker.io/v2/”: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
先展示一下拉取镜像最终的效果
使用的linux版本
consola@admin:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
安装(没有安装的 一键安装一下)
# 执行脚本
consola@admin:~$ sudo curl -fsSL https://github.com/tech-shrimp/docker_installer/releases/download/latest/linux.sh| bash -s docker --mirror Aliyun
[sudo] password for consola:
# Executing docker install script, commit: 39040d838e8bcc48c23a0cc4117475dd15189976
Warning: the "docker" command appears to already exist on this system.
If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.
If you installed the current Docker package using this script and are using it
again to update Docker, you can safely ignore this message.
You may press Ctrl+C now to abort this script.
+ sleep 20
+ sudo -E sh -c 'apt-get -qq update >/dev/null'
W: GPG error: http://mirrors.aliyun.com/ubuntu trusty-backports InRelease: Splitting up /var/lib/apt/lists/partial/mirrors.aliyun.com_ubuntu_dists_trusty-backports_InRelease into data and signature failed
E: The repository 'http://mirrors.aliyun.com/ubuntu trusty-backports InRelease' is not signed.
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy InRelease: Splitting up /var/lib/apt/lists/cn.archive.ubuntu.com_ubuntu_dists_jammy_InRelease into data and signature failed
E: The repository 'http://mirrors.aliyun.com/ubuntu trusty Release' does not have a Release file.
# 安装成功
consola@admin:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
可用的地址配置
- https://dockerpull.com
- https://docker.1panel.live
- https://dockerproxy.cn
- https://docker.hpcloud.cloud
# 查看镜像源网络是否通
consola@admin:~$ ping dockerpull.com
PING dockerpull.com (104.19.156.210) 56(84) bytes of data.
64 bytes from 104.19.156.210 (104.19.156.210): icmp_seq=1 ttl=128 time=237 ms
64 bytes from 104.19.156.210 (104.19.156.210): icmp_seq=2 ttl=128 time=217 ms
^C
--- dockerpull.com ping statistics ---
3 packets transmitted, 2 received, 33.3333% packet loss, time 2001ms
rtt min/avg/max/mdev = 216.864/227.032/237.201/10.168 ms
# 配置镜像源
consola@admin:~$ sudo tee /etc/docker/daemon.json <<-'EOF'
> {
> "registry-mirrors": ["https://dockerpull.com"]
> }
> EOF
{
"registry-mirrors": ["https://dockerpull.com"]
}
# 查看配置
consola@admin:~$ cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://dockerpull.com"]
}
# 重新加载配置
sudo systemctl daemon-reload
sudo systemctl restart docker
查看仓库是否配置成功
consola@admin:~$ docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
scan: Docker Scan (Docker Inc., v0.21.0)
Server:
ERROR: 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.24/info": dial unix /var/run/docker.sock: connect: permission denied
errors pretty printing info
consola@admin:~$ sudo docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
scan: Docker Scan (Docker Inc., v0.21.0)
Server:
Containers: 2
Running: 1
Paused: 0
Stopped: 1
Images: 2
Server Version: 20.10.21
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 770bd0108c32f3fb5c73ae1264f7e503fe7b2661
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: default
cgroupns
Kernel Version: 5.15.0-56-generic
Operating System: Ubuntu 22.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.59GiB
Name: admin
ID: FXAX:YYLS:B35K:3R26:IBJL:CUPU:CA3F:TIAI:LWHV:YBNU:AJHW:KXUW
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://dockerproxy.cn/
Live Restore Enabled: false
WARNING: API is accessible on http://0.0.0.0:2375 without encryption.
Access to the remote API is equivalent to root access on the host. Refer
to the 'Docker daemon attack surface' section in the documentation for
more information: https://docs.docker.com/go/attack-surface/
运行拉取一个镜像
consola@admin:~$ sudo docker run --name some-tomcat -p 8080:8080 -d tomcat
[sudo] password for consola:
Unable to find image 'tomcat:latest' locally
latest: Pulling from library/tomcat
32b824d45c61: Pull complete
fe18bb7e114f: Pull complete
581ebfe08d3f: Pull complete
7c7bdd063feb: Pull complete
28f1e2918031: Pull complete
dbce9ebf04f0: Pull complete
4f4fb700ef54: Pull complete
2963b9c3d96f: Pull complete
Digest: sha256:0298f25ea8171042fe610457ff0fd72382d36a144eae4483e2784bbbae31d68b
Status: Downloaded newer image for tomcat:latest
6771dcc20d1a3f54612074029b9f935ac4ceef088cc7b5b16af6560f0f027264
# 查看是否正常启动
consola@admin:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6771dcc20d1a tomcat "catalina.sh run" 14 minutes ago Up 14 minutes 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp some-tomcat
访问地址
- 本来这块已经算是安装启动完成了,但是有些朋友和我一样是一个强迫症必须要访问到界面才能舒服
查看日志(启动是成功的)
consola@admin:~$ sudo docker logs some-tomcat
27-Sep-2024 22:18:54.359 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/10.1.30
27-Sep-2024 22:18:54.364 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Sep 13 2024 20:26:16 UTC
27-Sep-2024 22:18:54.364 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.1.30.0
27-Sep-2024 22:18:54.365 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
27-Sep-2024 22:18:54.365 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 5.15.0-56-generic
27-Sep-2024 22:18:54.365 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
27-Sep-2024 22:18:54.365 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /opt/java/openjdk
27-Sep-2024 22:18:54.366 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 21.0.4+7-LTS
27-Sep-2024 22:18:54.366 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Eclipse Adoptium
27-Sep-2024 22:18:54.366 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat
27-Sep-2024 22:18:54.366 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat
27-Sep-2024 22:18:54.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
27-Sep-2024 22:18:54.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
27-Sep-2024 22:18:54.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
27-Sep-2024 22:18:54.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
27-Sep-2024 22:18:54.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
27-Sep-2024 22:18:54.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
27-Sep-2024 22:18:54.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
27-Sep-2024 22:18:54.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
27-Sep-2024 22:18:54.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
27-Sep-2024 22:18:54.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
27-Sep-2024 22:18:54.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
27-Sep-2024 22:18:54.376 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
27-Sep-2024 22:18:54.377 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
27-Sep-2024 22:18:54.379 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [2.0.8] using APR version [1.7.2].
27-Sep-2024 22:18:54.381 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 3.0.13 30 Jan 2024]
27-Sep-2024 22:18:54.554 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
27-Sep-2024 22:18:54.566 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [298] milliseconds
27-Sep-2024 22:18:54.590 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
27-Sep-2024 22:18:54.590 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.1.30]
27-Sep-2024 22:18:54.596 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
27-Sep-2024 22:18:54.604 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [37] milliseconds
consola@admin:~$ sudo docker exec -it some-tomcat /bin/bash
root@6771dcc20d1a:/usr/local/tomcat# cd /usr/local/tomcat/conf/
进入容器修改
# 进入容器
consola@admin:~$ sudo docker exec -it some-tomcat /bin/bash
root@6771dcc20d1a:/usr/local/tomcat# cd /usr/local/tomcat
root@6771dcc20d1a:/usr/local/tomcat# ll
total 176
drwxr-xr-x 1 root root 4096 Sep 17 22:58 ./
drwxr-xr-x 1 root root 4096 Sep 17 22:58 ../
drwxr-xr-x 2 root root 4096 Sep 17 22:58 bin/
-rw-r--r-- 1 root root 21039 Sep 13 20:26 BUILDING.txt
drwxr-xr-x 1 root root 4096 Sep 27 22:18 conf/
-rw-r--r-- 1 root root 6166 Sep 13 20:26 CONTRIBUTING.md
drwxr-xr-x 2 root root 4096 Sep 17 22:58 lib/
-rw-r--r-- 1 root root 60393 Sep 13 20:26 LICENSE
drwxrwxrwt 1 root root 4096 Sep 27 22:18 logs/
drwxr-xr-x 2 root root 4096 Sep 17 22:58 native-jni-lib/
-rw-r--r-- 1 root root 2333 Sep 13 20:26 NOTICE
-rw-r--r-- 1 root root 3298 Sep 13 20:26 README.md
-rw-r--r-- 1 root root 6776 Sep 13 20:26 RELEASE-NOTES
-rw-r--r-- 1 root root 16109 Sep 13 20:26 RUNNING.txt
drwxrwxrwt 2 root root 4096 Sep 17 22:58 temp/
drwxr-xr-x 2 root root 4096 Sep 17 22:58 webapps/
drwxr-xr-x 7 root root 4096 Sep 13 20:26 webapps.dist/
drwxrwxrwt 2 root root 4096 Sep 13 20:26 work/
# 替换一下目录
root@6771dcc20d1a:/usr/local/tomcat# rm -rf webapps
root@6771dcc20d1a:/usr/local/tomcat# mv webapps.dist webapps
再次访问(舒服了)
有条件的朋友记得赞一下
借鉴的博客
- https://cloud.tencent.com/developer/article/1704573