守望先锋代码
介绍 (Introduction)
I’ve been working with SQL Server in containers for a while now and one of the challenges that I have is ensuring that the databases within them are kept at the correct version. This is important because you don’t want your development teams testing against databases that have an out of date schema (or reference data).
我使用容器中SQL Server已有一段时间了,我面临的挑战之一是确保其中的数据库保持正确的版本。 这很重要,因为您不希望开发团队针对具有过期架构(或参考数据)的数据库进行测试。
The databases that I store in my container image are updated on a weekly basis and currently, the process to update our containers is manual. Once the updated image has been created, the existing running containers are dropped and new ones created from the updated image.
我存储在容器映像中的数据库每周更新一次,目前,更新容器的过程是手动的。 创建更新的映像后,将删除现有的正在运行的容器,并根据更新的映像创建新的容器。
But what if we could automatically refresh our containers with the updated image? If we could do that then the only process that’s manual is updating the image. We would no longer have to worry about any containers running SQL instances with databases that are out of date.
但是,如果我们可以使用更新的图像自动刷新容器,该怎么办? 如果我们能够做到这一点,那么唯一的手动过程就是更新映像。 我们不再需要担心任何运行SQL实例且数据库已过时的容器。
Luckily, there’s a way to do this and it’s accessible via an image on the Docker Hub called Watchtower. What Watchtower does is monitor the Docker Hub and if there’s an update to an image it will automatically refresh all running containers that are on the same host.
幸运的是,有一种方法可以通过Docker Hub上名为Watchtower的映像进行访问。 Watchtower的工作是监视Docker Hub,如果更新了映像,它将自动刷新同一主机上的所有正在运行的容器。
This article will guide you through the setup of this process and how to run a simple test.
本文将指导您完成此过程的设置以及如何运行简单的测试。
先决条件 (Pre-requisites)
What you will need to run through this process is:
完成此过程需要执行的操作是:
- Two Linux VMs with internet access (referred to as Linux1 & Linux2) 两个具有Internet访问权限的Linux VM(称为Linux1和Linux2)
- here 此处的说明进行操作
- here 此处的说明进行操作
Craft.io概述 (Process Overview)
Getting this working involves a few steps. Here is an overview of the process. The initial setup involves (on Linux1):
使这项工作涉及几个步骤。 这是该过程的概述。 初始设置涉及(在Linux1上):
- Creating a custom SQL image with a test database 使用测试数据库创建自定义SQL映像
- Creating a repository in the Docker Hub 在Docker Hub中创建存储库
- Pushing the custom image to the Docker Hub 将自定义映像推送到Docker Hub
Once the setup is complete, we’ll start up Watchtower and run a test. The steps I’ll run through are:
设置完成后,我们将启动“守望台”并运行测试。 我将执行的步骤是:
-
- Pulling the Watchtower image from the Docker Hub 从Docker集线器中获取城楼镜像
- Running Watchtower in a container 在容器中运行Watch望塔
- Creating two SQL containers from the custom image created in the initial setup. 从在初始设置中创建的自定义映像创建两个SQL容器。
-
- Creating an updated image to replace the one in the Docker Hub. 创建一个更新的映像以替换Docker Hub中的映像。
- Pushing the updated image to the Docker Hub 将更新的映像推送到Docker Hub
-
- Check to see if containers have been updated automatically 检查容器是否已自动更新
设置–在Linux 1上 (Setup – On Linux 1)
Create a SQL container
创建一个SQL容器
To get started with creating a custom image, the first thing I will do is spin up a container using the docker run command:
要开始创建自定义图像,我要做的第一件事是使用docker run命令启动一个容器:
- docker run -d -p 15789:1433 –env ACCEPT_EULA=Y –env SA_PASSWORD=Testing1122
- docker run -d -p 15789:1433 –env ACCEPT_EULA = Y –env SA_PASSWORD = Testing1122
- –name testcontainer microsoft/mssql-server-linux
- –名称测试容器microsoft / mssql-server-linux

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/53607.html