$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
docker exec -it 容器id bash
sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list
docker封装cms的基本思路
1.下载一个LAMP环境(不一定是LAMP根据实际情况pull)
docker pull image_name:versionx
2 启动环境(根据实际情况选择参数,镜像id通过docker image 查看)
dcoekr run -d --name=lamp -p 80:80 -v /mysql_data:/var/lib/mysql 镜像id
3.进入容器(docker ps 查看容器id)
docker exec -it 容器id bash
4.切换到web路径,使用wegt命令将cms添加的docker容器中,也可在第二步中直接挂在进去
5.cms的正常安装
6.退出容器,并暂停容器
7.将容器封装为镜像,如果有本地挂载,同时保存一份本地挂载的文件,以便复现时导入
8. 将容器镜像打包
dockerfile封装CMS基本思路
1、编写Dockerfile
FROM ubuntu:18.04 # 从哪个镜像基础上开始操作
# 作者,不是必须的
LABEL maintainer="phithon <root@leavesongs.com>"
#运行的时候默认选择Y,不安装非必须的依赖包(shell尽量放在一层上)
RUN apt-get install -y --no-install-recommends
# 不安装非必须依赖包
RUN pip --no-cache-dir install httpstat
ADD
# 如果使用的是集成环境,可以使用ENV设置环境中MySQL_ROOT的默认密码
ENV MYSQL_ROOT_PASSWORD=password
2、运行命令封装为镜像
docker build -t 镜像名 .
示例:
FROM thiagobarradas/lamp:php-7.2
RUN rm -rf /app
COPY ./apps /app
ENV MYSQL_PASS=admin
# RUN mysql -e "set password for 'root'@'localhost' = password('root');"
EXPOSE 80 3306
CMD ["/run.sh"]
# 参考链接:
# https://hub.docker.com/r/tutum/lamp
#
#
四、常见问题
1、docker pull的时候出错
error pulling image configuration: Get https://production.cloudflare.docker.com/
registry-v2/docker/registry/v2/blobs/sha256/1c/1cda43d811c8fb178d9b0aacbdfaaa4e4
f36489e2112558c84a97549f868585c/data?verify=1608172124-zf3G3JFGipnlE3G24jL3h8nIKg
w%3D: dial tcp: lookup production.cloudflare.docker.com: Temporary failure in name
resolution
步骤如下:
1、编辑 /etc/resolv.conf 文件,在文件中添加如下内容:
nameserver 8.8.8.8
2、保存并推出,之后重启docker服务
2、docker pull: "No address associated with hostname"
# 报错内容---ubuntu18.04
Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io: No address associated with hostname