使用下面的命令运行镜像。-it 表示交互,但是不知道为什么执行命令并没有交互,似乎和-d命令冲突了;-p 是端口映射,将本地的xx端口映射到容器的22端口便于ssh连接;–name 表示容器的名字,用于标识;–restart 是Restart policy to apply when a container exits (default “no”);-d 是Run container in background and print container ID; 最后是 image:TAG ,和要执行的命令。
username@device_name:~$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES bd7e12345678 ubuntu:18.04 "bash" 3 minutes ago Up 3 minutes 0.0.0.0:40500->22/tcp, :::40500->22/tcp Ubuntu-18.04-test
root@bd7e12345678:/# apt update Ign:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic InRelease Ign:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates InRelease Ign:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports InRelease Ign:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security InRelease Err:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic Release Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443] Err:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates Release Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443] Err:7 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports Release Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443] Err:8 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security Release Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443] Reading package lists... Done W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic/InRelease: No system certificates available. Try installing ca-certificates. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-updates/InRelease: No system certificates available. Try installing ca-certificates. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-backports/InRelease: No system certificates available. Try installing ca-certificates. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-security/InRelease: No system certificates available. Try installing ca-certificates. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic/Release: No system certificates available. Try installing ca-certificates. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-updates/Release: No system certificates available. Try installing ca-certificates. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-backports/Release: No system certificates available. Try installing ca-certificates. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-backports Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-security/Release: No system certificates available. Try installing ca-certificates. E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.