根据之前的内容基础,本小点的内容主要涉及到的内容是比较重要的文本Dockerfile
启动命令行终端(在自己的工作空间当中),创建和编辑Dockerfile。
vim Dockerfile
然后写入以下内容
# 使用一个基础镜像
FROM ubuntu:latest
# 换源
RUN cp /etc/apt/sources.list /etc/apt/sources.list.bk
COPY sources.list /etc/apt/sources.list
#更新源
RUN apt-get update
# 安装所需的软件包(这里以安装curl和vim为例)
RUN apt-get update && apt-get install -y curl vim
# 容器启动时执行的命令
CMD ["/bin/bash"]
FROM ubuntu:latest
RUN cp /etc/apt/sources.list /etc/apt/sources.list.bk
COPY sources.list /etc/apt/sources.list
RUN apt-get update
RUN apt-get update && apt-get install -y curl vim
CMD ["/bin/bash"]
在这里使用阿里云源作为文件替换,也就是对应Dockerfile文件当中的sources.list文件,在当前工作目录下新建就好了。
vim sources.list
然后粘贴以下内容
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
docker build -t test:docker_v1 .
docker images
docker run -it test:docker_v1
apt-get update
curl -v www.baidu.com
vim /etc/apt/sources.list
没问题的话如下几张图所示:
可以查看系统信息
完结撒花
Redamancy