我正在使用 Docker。我是这项技术的新手,所以如果需要任何其他信息,请告诉我
想要安装远程主机,
docker-compose.yml
version: '3.8'
services:
jenkins:
container_name: jenkins
image: jenkins/jenkins
ports:
- "8080:8080"
volumes:
- "$PWD/jenkins_home:/var/jenkins_home"
networks:
- net
remote_host:
container_name: remote-host
image: remote-host
build:
context: centos
networks:
- net
networks:
net:
Docker文件:
FROM centos
RUN dnf install openssh-server
RUN useradd remote_user && \
echo "remote_user:1234" | chpasswd && \
mkdir /home/remote_user/.ssh && \
chmod 700 /home/remote_user/.ssh
COPY remote-key.pub /home/remote_user/.ssh/authorized_keys
RUN chown remote_user:remote_user -R /home/remote_user/.ssh/ && \
chmod 600 /home/remote_user/.ssh/authorized_keys
RUN ssh-keygen -A
CMD /usr/sbin/sshd -D
我面临的异常
[jenkins@localhost jenkins-data]$ docker compose build
[+] Building 4.1s (6/10)
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 516B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/centos:latest 1.9s
=> CACHED [1/6] FROM docker.io/library/centos@sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177 0.0s
=> [internal] load build context 0.1s
=> => transferring context: 95B 0.0s
=> ERROR [2/6] RUN dnf install openssh-server 2.0s
------
> [2/6] RUN dnf install openssh-server:
#0 1.808 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
#0 1.809 CentOS Linux 8 - AppStream 67 B/s | 38 B 00:00
------
failed to solve: process "/bin/sh -c dnf install openssh-server" did not complete successfully: exit code: 1
[jenkins@localhost jenkins-data]$ cd
[jenkins@localhost ~]$
[jenkins@localhost ~]$
[jenkins@localhost ~]$ ping google.com
PING google.com (142.250.199.142) 56(84) bytes of data.
64 bytes from bom07s36-in-f14.1e100.net (142.250.199.142): icmp_seq=1 ttl=117 time=9.28 ms
64 bytes from bom07s36-in-f14.1e100.net (142.250.199.142): icmp_seq=2 ttl=117 time=9.03 ms
答案1
这centos
docker 镜像被标记为已贬值且不再受支持/维护。