docker使用

发布时间 2023-04-24 10:09:19作者: 狎客

:此文档运行环境为wsl

1 安装使用

1.1 命令

[[wsl安装使用]]

wsl --shutdown

service mysql start
service mysql stop

service redis-server start
service redis-server stop

service docker start
service docker stop

查看docker信息

sudo docker info
docker version

搜索可用docker镜像

docker search <image>
docker search tutorial

1.2 使用过程中发现的问题

"WARNING: No blkio throttle.read_bps_device support"

  1. 场景:运行命令sudo docker into查看安装好的docker信息
  2. 报错:Warning
    image
  3. 原因:了解blkio
  4. 解决:不需要解决此警告

"Cannot create /tmp/remote-wsl-loc.txt: Permission denied"

  1. 场景:运行命令code .打开vscode
  2. 报错:
    image
  3. 原因:曾经用root用户执行code命令,创建了文件"/tmp/remote-wsl-loc.txt",普通用户使用时权限不够
  4. 解决:可以更改文件权限,也可以直接删除该文件,然后重新在普通用户环境执行code .
sudo rm -f /tmp/remote-wsl-loc.txt
code .

疑问

2 概念

2.1 docker and containers and images

Docker provides the ability to package and run an application in a loosely isolated environment called a container.

Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的、可移植的、自给自足的容器

A container is a sandboxed process on your machine that is isolated from all other processes on the host machine.

容器是一种沙盒技术,主要目的是为了将应用运行在其中,与外界隔离

An image is a read-only template with instructions for creating a Docker container.

镜像,是一个只读模板,含创建Docker容器的说明,它与操作系统的安装光盘有点像。(镜像是一个特殊的文件系统,除了提供容器运行时所需的程序、库、资源、配置等文件外,还包含了一些为运行时准备的配置参数)