Docker Issues in Development
pip freeze > requirements.txt
touch Dockerfile
vim Dockerfile
FROM python:3.10.12
ADD . /code
WORKDIR /code
# Install Dependencies
RUN pip install -r requirements.txt
CMD ["python", "/hello.py"]
docker build -t demo .
docker run -it demo
docker run -itd --name demo -p 5000:5000 demo
[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
docker push docker_username/REPOSITORY:TAG
[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 ~]#
[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 ~]#
[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许可协议。获得许可后,要求转载时注明文章出处和网站链接,谢谢!