简体   繁体   中英

Cannot install Docker container for SQL Server

I am trying to install SQL Server on my Docker but I am not sure if I should create a Docker container first and then install SQL Server image eg mcr.microsoft.com/mssql/server 2019-CU4-ubuntu-18.04 . I have a SQL Server database container but I want to create a new container for this new database.

I tried to run this command via cmd , but it does not create a container (I am not sure if I should restart Docker to see the changes).

docker pull mcr.microsoft.com/mssql/server:2019-CU4-ubuntu-18.04

There is a message: "Status: Image is up to date for mcr.microsoft.com/mssql/server:2019-CU4-ubuntu-18.04" . I think it is due to that it already installed. But I am not sure how can I create a new container using this image (for SQL Server database).

Another issue as I have no experience with Docker , should I use cmd , Windows Power Shell , etc. for running Docker commands?

Tipically, there is a Docker image with SQL Server, and a container is ran based on this. So, if you perform a docker run (as in the instructions of the next link) you would be pulling the image from the Docker Hub repository - getting a copy of the image to your machine, if you still don't have one - and creating a running container based on the image.

Please look at this article for a complete walkthrough on building an MSSQL Docker container.

To run two containers from the same image, use diferent names, ports and volumes - since it is a database - for each container, and that should do. Please, check this example .

Regarding the consoles, you can use any of your choice. Using Windows, personally I prefer a "shell-like" console, like Git Bash or WSL shell . Docker is Linux, so for me it makes sense to use a "Linux-like" environment and commands. But you only have to install the Docker Desktop , then it is up to you. Aditionally, you can install the Docker extension for Visual Studio Code or any other manager, since it allows you to manage your containers, images, volumes, etc. very easily:)

Concerning the volumes strategy, that depends on what you want to do with the container. If you don't specify any volume, you will lose all the data, once you delete the container. If you use a named volume, you let Docker manage the location of the information, but it becomes attached to that name and you can see that in your volumes list; you'll lose the data only if you delete that specific volume. Whereas if you use a volume mounted to an external location, for example in your file system, you can specify that the data is stored in such location; only if you go to the location and delete the data, will the information be lost. So, it's up to your use case:)

Docker documentation on volumes is quite good and you can read here the differences between named and path based volumes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM