docker learn

旧城等待, 2023-05-30 15:53 184阅读 0赞

ubuntu 安装docker

参考https://docs.docker.com/engine/install/ubuntu/

  1. sudo apt-get remove docker docker-engine docker.io containerd runc
  2. $ sudo apt-get update
  3. $ sudo apt-get install \
  4. apt-transport-https \
  5. ca-certificates \
  6. curl \
  7. gnupg-agent \
  8. software-properties-common
  9. $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  10. $ sudo apt-key fingerprint 0EBFCD88
  11. pub rsa4096 2017-02-22 [SCEA]
  12. 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
  13. uid [ unknown] Docker Release (CE deb) <docker@docker.com>
  14. sub rsa4096 2017-02-22 [S]
  15. $ sudo add-apt-repository \
  16. "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  17. $(lsb_release -cs) \
  18. stable"
  19. $ sudo apt-get update
  20. $ sudo apt-get install docker-ce docker-ce-cli containerd.io
  21. $ sudo docker run hello-world

第一个docker Dockerfile

  1. # Dockerfile
  2. FROM ubuntu

build

  1. $ docker build -t carl/learn:1.0 .

运行

  1. $ docker run -it carl/learn:1.0 bash

退出来以后什么也不会保存。可以在退出前,在另外的窗口提交更改

  1. $ docker ps
  2. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  3. c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
  4. 197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
  5. $ docker commit c3f279d17e0a carl/learn:1.1
  6. f5283438590d
  7. $ docker images
  8. REPOSITORY TAG ID CREATED SIZE
  9. svendowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB

how to copy file from docker container to local host

https://stackoverflow.com/questions/22049212/copying-files-from-docker-container-to-host

docker cp :/file/path/within/container /host/path/target

$ sudo docker cp goofy_roentgen:/out_read.jpg .

如何保存image

You will need to save the Docker image as a tar file:

  1. docker save -o <path for generated tar file> <image name>

Then copy your image to a new system with regular file transfer tools such as cp, scp or rsync(preferred for big files). After that you will have to load the image into Docker:

  1. docker load -i <path to image tar file>

PS: You may need to sudo all commands.

EDIT: You should add filename (not just directory) with -o, for example:

  1. docker save -o c:/myfile.tar centos:16

如何将Docker容器通过独立IP暴露给局域网

  • 参考https://www.cnblogs.com/Jing-Wang/p/10848960.html
  • 参考https://blog.csdn.net/lvshaorong/article/details/69950694

参考

How to copy Docker images from one host to another without using a repository?

https://docs.docker.com/engine/reference/commandline/commit/

发表评论

表情:
评论列表 (有 0 条评论,184人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Make-learning

    Make学习笔记 > make是工具,Makefile是指导make工作的文件,而CMake则是生成Makefile的工具 要点: 1. 终极目标是Makefile

    相关 learning rate

    本文从梯度学习算法的角度中看学习率对于学习算法性能的影响,以及介绍如何调整学习率的一般经验和技巧。 在机器学习中,监督式学习(Supervised Learning)通过定义

    相关 Docker遇见Deep Learning

    序 阅读本篇文章可以帮你解决的问题是:提供一套解决方案,能够在支持Docker的任何版本Ubuntu系统下,搭建出完美运行各种深度学习框架、各种版本、各种环境依赖(NAI