1.安装Docker

首先按照网上的教程安装好Docker
开始安装
由于apt官方库里的docker版本可能比较旧,所以先卸载可能存在的旧版本:

$ sudo apt-get remove docker docker-engine docker-ce docker.io

更新apt包索引:

$ sudo apt-get update

安装以下包以使apt可以通过HTTPS使用存储库(repository):

$ sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common

添加Docker官方的GPG**:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

使用下面的命令来设置stable存储库:

$ sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”

再更新一下apt包索引:

$ sudo apt-get update

安装最新版本的Docker CE:

$ sudo apt-get install -y docker-ce

验证是否已经安装
服务计算——docker实践

运行第一个容器

运行镜像:
服务计算——docker实践

2.Docker 基本操作

运行镜像
服务计算——docker实践
显示本地镜像库内容
服务计算——docker实践
显示运行中容器
服务计算——docker实践
显示所有容器(包含已中止)
服务计算——docker实践

3.MySQL与容器化

构建docker镜像练习

创建文件并录入

mkdir mydock && cd mydock
mydock]# vi dockerfile
服务计算——docker实践

构建镜像
服务计算——docker实践
运行镜像
服务计算——docker实践

MySQL

拉取 MySQL 镜像
服务计算——docker实践
使用MySQL容器

  • 启动服务器
    服务计算——docker实践
  • 启动 MySQL 客户端
    服务计算——docker实践
  • 基本操作
    服务计算——docker实践
    使用MySQL容器(挂载卷保存db)
    服务计算——docker实践
    服务计算——docker实践
    创建卷并挂载
    服务计算——docker实践
    启动客户端容器链接服务器
    服务计算——docker实践
    服务计算——docker实践

4.Docker仓库

按照官方教程.进行操作:

Run a local registry

Use a command like the following to start the registry container:
服务计算——docker实践

Copy an image from Docker Hub to your registry

1.Pull the ubuntu:16.04 image from Docker Hub.

$ docker pull ubuntu:16.04

服务计算——docker实践

2.Tag the image as localhost:5000/my-ubuntu. This creates an additional tag for the existing image. When the first part of the tag is a hostname and port, Docker interprets this as the location of a registry, when pushing.

$ docker tag ubuntu:16.04 localhost:5000/my-ubuntu

服务计算——docker实践

3.Push the image to the local registry running at localhost:5000:

$ docker push localhost:5000/my-ubuntu

服务计算——docker实践
4.Remove the locally-cached ubuntu:16.04 and localhost:5000/my-ubuntu images, so that you can test pulling the image from your registry. This does not remove the localhost:5000/my-ubuntu image from your registry.

$ docker image remove ubuntu:16.04
$ docker image remove localhost:5000/my-ubuntu

服务计算——docker实践
5.Pull the localhost:5000/my-ubuntu image from your local registry.

$ docker pull localhost:5000/my-ubuntu

服务计算——docker实践

Stop a local registry

To stop the registry, use the same docker container stop command as with any other container.

$ docker container stop registry

To remove the container, use docker container rm.

$ docker container stop registry && docker container rm -v registry

服务计算——docker实践

相关文章:

  • 2021-11-28
  • 2022-01-13
  • 2021-11-28
  • 2022-01-07
  • 2021-12-24
  • 2021-12-21
猜你喜欢
  • 2021-07-17
  • 2021-06-28
  • 2022-01-11
  • 2021-03-26
  • 2021-11-13
  • 2022-12-23
  • 2021-07-05
相关资源
相似解决方案