0
点赞
收藏
分享

微信扫一扫

Docker————数据卷容器,容器互联,镜像创建

未定义变量 2024-07-25 阅读 31
docker

0 Preface/Foreward

0.1 参考文档

Overview of Docker Desktop | Docker Docs (Docker Desktop使用手册)

0.1.1 Docker Dashboard

Before going any further, we want to highlight the Docker Dashboard, which gives you a quick view of the containers running on your machine. It prvovides you access to container logs, lets you get a shell inside the container, and allows you to easily manage container lifecycle (stop, remove, etc.).

0.1.2 What is a container?

Simply put, a container is another process on your machine that has been isolated from all other processes on the host machine. That isolation leverages kernel namespaces and cgroups, features that have been in Linux for a long time. Docker has worked to make these capabilities approachable and easy to use.

0.1.3 What is a container image?

When running a container, it uses an isolated filesystem. This custom filesystem is provided by a container image. Since the image contains the container's filesystem, it must include everyting needed to run the application - all dependencies, configuration, scripts, binaries, etc. The image also contains other configuration for the container, such environment variables, a default command to run, and other metadata.

0.2 Docker Desktop介绍

 0.2.1 Overview

Docker Desktop is one-click-install application for your Mac, Linux, or Windows environment that lets you build, share, and run containerized applications and microservices.

It provides a straightforward GUI (Graphical User Interface) that lets you manage your containers, applications, and images directly from your machine.

Docker Desktop reduces the time spent on complex setups so you can focus on writing code. It takes care of port mappings, file system concerns, and other default settings, and is regularly updated with bug fixed and security updated. 

What's included in Docker Desktop?

  • Docker Engine
  • Docker CLI clent
  • Docker build

0.2.2 Docker Engine

 Docker Engine is an open source containerization technology for building and containerizing your applications. Docker Engine acts as a client-server application with:

  • A server with a long-running daemon process dockerd
  • APIs which specify interfaces that programs can use to talk to and instrcut the Docker daemon.
  • A command line interface (CLI) client docker

0.2.3 Docker Build

Docker build is one of Docker Engine's most used features. Whenever you are creating an image you are using Docker Build. Build is a key part of your software development life cycle allowing you to package and bundle your code and ship it anywhere.

Docker build is more than a command for buiding images, and it's not only about packaging your code. It's a whole ecosystem of tools and features that support not only common workflow tasks but also provides support for more complex and advanced scenarios.

1 安装

1.1 运行docker安装包

安装完Docker Desktop后,运行Docker Desktop,出现WSL 2安装不完整情况,具体情况如下: 

解决方法:旧版 WSL 的手动安装步骤 | Microsoft Learn

也可以直接下载新的安装包,然后安装。https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

1.2 开始使用Docker

 1.2.1 Clone a repository

 1.2.2 Build the image

 

 

 

 1.2.3 Run your first container

 

 

命令分析

You will notice that a few flags being used, here is some more info on them:

  • -d - run the container in detached mode (in the background/backend)
  • -p 80:80 - map port 80 of the host to port 80 in the container
  • docker/getting-started - the image to run

Pro tip: Professional tip (专业提示)

 1.2.4 Share

 

2 使用

2.1 启动Docker

注意:要启动Docker,需要登陆账号。

 2.2 为WSL distro激活Docker desktop

 

 参考上面的建议文档:https://docs.docker.com/desktop/wsl/

 根据上面提醒,在Docker Desktop设置界面:settings > Resources > WSL INTEGRATION

选中默认的WSL distro(可以按照多个发行版本),当前只安装了一个发行版本,所以Ubuntu-18.04就是默认的发行版本。

激活成功WSL Docker Desktop,输入docker命令,显示Usage 命令文本:

2.3 Docker Desktop启动的WSL distro

 Docker Desktop 安装了两个special-purpose internal Linux distros:都不能用作通用开发

  • docker-desktop:用来运行Docker engine (dockerd)
  • docker-desktop-data:存储容器(containers)和镜像(image)。

举报

相关推荐

0 条评论