Docker安装+镜像拉取+容器+创建镜像+push to docker hub
生活随笔
收集整理的這篇文章主要介紹了
Docker安装+镜像拉取+容器+创建镜像+push to docker hub
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 1. 安裝
- 2. 鏡像操作
- 3. 容器
- 4. docker hub
本文參考:https://zhuanlan.zhihu.com/p/23599229
1. 安裝
- 參考 https://www.runoob.com/docker/ubuntu-docker-install.html
- 測試(centos環(huán)境)安裝成功 docker run hello-world
- 查看版本 docker version
2. 鏡像操作
- 查找鏡像 docker search centos
- 拉取鏡像 docker pull centos,會拉取最新的版本
- 列出鏡像 docker images
3. 容器
- 通過鏡像,啟動容器 docker run -it centos:latest /bin/bash
- -i 交互式,-t終端,-d 后臺運行
- @后面變了,進入容器了,查看是否有 git git --version,沒有就安裝 yum install git
- exit 退出容器,docker ps -a查看容器運行程序的情況
- 創(chuàng)建鏡像,并提交 docker commit -m "centos with git" -a "kobe24o" 父容器id kobe24o/centos:git
或者通過 配置文件來創(chuàng)建 vim dockerfile
# 說明該鏡像以哪個鏡像為基礎 FROM centos:latest# 構建者的基本信息 MAINTAINER kobe24o# 在build這個鏡像時執(zhí)行的操作 RUN yum update RUN yum install -y git# 拷貝本地文件到鏡像中 COPY ./* /usr/share/gitdir/輸入命令docker build -t="kobe24o/centos:test" .
- 刪除操作容器 docker rm 容器id
- 刪除鏡像 docker rmi 鏡像name 或者 id,如 docker rmi kobe24o/centos:test
4. docker hub
-
登錄 docker login,輸入用戶名,密碼
-
把創(chuàng)建的鏡像 push 到 hub 上,docker push kobe24o/centos:git
-
以后自己和別人可以下載 docker pull kobe24o/centos:git
總結
以上是生活随笔為你收集整理的Docker安装+镜像拉取+容器+创建镜像+push to docker hub的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LeetCode 1679. K 和数对
- 下一篇: LeetCode 642. 设计搜索自动