前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >Common Docker Operations and Commands

Common Docker Operations and Commands

作者头像
alanzeng
发布2025-01-14 21:35:02
发布2025-01-14 21:35:02
5800
代码可运行
举报
文章被收录于专栏:alanzeng423alanzeng423
运行总次数:0
代码可运行

Docker Issues in Development

Common Docker Operations and Commands

Create Docker Image for Python Projects

  1. Configure Dependencies
代码语言:javascript
代码运行次数:0
复制
pip freeze > requirements.txt
touch Dockerfile
vim Dockerfile
  1. Create and Edit Dockerfile
代码语言:javascript
代码运行次数:0
复制
FROM python:3.10.12
ADD . /code
WORKDIR /code
# Install Dependencies
RUN pip install -r requirements.txt
CMD ["python", "/hello.py"]
  1. Build Docker Image & run
代码语言:javascript
代码运行次数:0
复制
docker build -t demo .
docker run -it demo
docker run -itd --name demo -p 5000:5000 demo

Pull or Push Docker Images

Docker Hub

login to Docker Hub;

代码语言:javascript
代码运行次数:0
复制
[root@localhost ~]
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username:          
Password:         
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

Edit Tag

  • Push Command docker push docker_username/REPOSITORY:TAG
  • We need to edit the tag and repository name:
代码语言:javascript
代码运行次数:0
复制
[root@localhost ~]# docker images 
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
demo                latest              1e5f6711d527        3 days ago          178MB
[root@localhost ~]# docker tag demo:latest ***/demo:v1
[root@localhost ~]# docker images 
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
demo                latest              1e5f6711d527        3 days ago          178MB
***/demo            v1                  1e5f6711d527        3 days ago          178MB
[root@localhost ~]# 

Push

代码语言:javascript
代码运行次数:0
复制
[root@localhost ~]# docker push ***/demo:v1
The push refers to repository [docker.io/***/demo:v1]
833a0t6a6ff9: Pushed 
10bfe4y2500e: Pushed 
d43sfdd7d594: Mounted from library/nginx 
c2adabsadfed: Mounted from library/nginx 
v1: digest: sha256:67dcdae5578c0374019bdc899731543cfd7c48fe5780e84233a258f2bf7d2ceda size: 1155
[root@localhost ~]# 

Pull

代码语言:javascript
代码运行次数:0
复制
[root@localhost ~]# docker pull ***/demo:v1
v1: Pulling from ***/demo:v1
Digest: sha256:67dcdae5578c0374019bdc899731543cfd7c48fe5780e84233a258f2bf7d2ceda
Status: Downloaded newer image for ***/demo:v1
docker.io/llxxyy/nginx-io:v1

文章作者: Alan Zeng

原始链接: https://alanzeng.com/blogs/31196/

版权说明:本博客所有文章除特别声明外,均采用BY-NC-SA 4.0许可协议。获得许可后,要求转载时注明文章出处和网站链接,谢谢!

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-08-02,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Common Docker Operations and Commands
    • Create Docker Image for Python Projects
    • Pull or Push Docker Images
      • login to Docker Hub;
      • Edit Tag
      • Push
      • Pull
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档