天马行空  
I ---- Inject 投入 L ---- Loyal 忠诚 O ---- Observant 用心 V ---- Valiant 勇敢 E ---- Enjoyment 喜悦 Y ---- Yes 愿意 O ---- Obligation 责任

 

Docker Desktop for Linux and Docker Engine can be installed side-by-side on the same machine. Docker Desktop for Linux stores containers and images in an isolated storage location within a VM and offers controls to restrict its resources. Using a dedicated storage location for Docker Desktop prevents it from interfering with a Docker Engine installation on the same machine.

在home电脑上同时装了Docker Desktop for Linux and Docker Engine ,目前带sudo执行docker命令都是Docker Engine ,否则是Docker Desktop 。(sudo有时候会出现找不到命令,而明明PATH路径下包含该命令,让人疑惑。其实出现这种情况的原因,主要是因为当 sudo以管理权限执行命令的时候,linux将PATH环境变量进行了重置,当然这主要是因为系统安全的考虑,但却使得sudo搜索的路径不是我们想要的PATH变量的路径,当然就找不到我们想要的命令了。)

(Docker Desktop on Linux runs a Virtual Machine (VM) so creates and uses a custom docker context desktop-linux on startup.

This means images and containers deployed on the Linux Docker Engine (before installation) are not available in Docker Desktop for Linux.)

文件位置:(Docker Desktop stores Linux containers and images in a single, large “disk image” file in the Linux filesystem. This is different from Docker on Linux, which usually stores containers and images in the /var/lib/docker directory on the host’s filesystem.

Where is the disk image file?

To locate the disk image file, select Settings from the Docker Dashboard then Advanced from the Resources tab.

The Advanced tab displays the location of the disk image. It also displays the maximum size of the disk image and the actual space the disk image is consuming. Note that other tools might display space usage of the file in terms of the maximum file size, and not the actual file size.) 

 

docker version 

 

sudo docker run --rm --runtime=nvidia --gpus all nvidia/cuda:12.0.1-base-ubuntu22.04 nvidia-smi

sudo docker run --name TFG -i -t --runtime=nvidia --gpus all tensorflow/tensorflow:latest-gpu

  

docker run -it --rm tensorflow/tensorflow    python -c "import tensorflow as tf; print(tf.__version__)"

docker run -it --rm tensorflow/tensorflow:latest-gpu    python -c "import tensorflow as tf; print(tf.__version__)"

 

sudo docker run -it --name TFG_j --gpus all -p 8888:8888 tensorflow/tensorflow:latest-gpu-jupyter

http://127.0.0.1:8888/?token=537a70e07081f08bf3059d1fa6678acc70024b96cabdf245

 

 

stop the Docker Engine service:

sudo systemctl stop docker docker.socket containerd

sudo systemctl start docker docker.socket containerd

 

 disable the Docker Engine service, and to prevent it from starting automatically:

sudo systemctl disable docker docker.socket containerd

sudo systemctl enable docker docker.socket containerd

 

switch between Docker Desktop and Docker Engine

docker context ls
docker context use default
docker context use desktop-linux

see the detailed space usage information by running:
docker system df -v

list containers, run:
docker container ls -a
docker ps -a 查看所有容器

启动容器:
sudo docker container start TFG   <name>
交互启动容器:
sudo docker container start -i TFG_j   <name> 
sudo docker container start -i TFG

  

入容器的shell界面 

  sudo docker attach exciting_cori <name>

 

If there are lots of redundant objects, run the command:

 docker system prune

适合bind mounts的场景

  • 宿主机和容器共享配置文件。Docker提供的DNS解决方案就是如此,将宿主机的/etc/resolv.conf挂载到每个容器中。
  • 开发环境需要在宿主机和容器中共享代码。docker的开发就是如此,毕竟容器中一般是没有编辑器的
  • When the file or directory structure of the Docker host is guaranteed to be consistent with the bind mounts the containers require.

SRC=/media/...
docker run -it --name tf --mount type=bind,src=${SRC},dst=${SRC} tensorflow/tensorflow

sudo docker run --name TFG -i -t --runtime=nvidia --gpus all --mount type=bind,src=${SRC},dst=${SRC} --mount type=bind,src=${sourceSRC},dst=${sourceSRC} tensorflow/tensorflow:latest-gpu

posted on 2023-02-08 10:20  浅蓝  阅读(49)  评论(0编辑  收藏  举报