If we clone that repo down, we’ll get the following: – I’ve created a GitHub repository here with all the necessary files: – The solution here is to create a custom image with the volume created and permissions set.īut wouldn’t it be easier to just have to run one command to spin up a custom 2019 image, with volumes created and permissions set? This is a good thing but it means that after the container comes up, we have to run: –ĭocker exec -u 0 testcontainer bash -c "chown mssql /var/opt/sqlserver" This is because SQL in 2019 runs as non-root. That’s a lot of typing! And if we try to create a database with the default values set in that statement, we’ll get the following error: –ĬREATE FILE encountered operating system error 2(The system cannot find the file specified.) while attempting to open or create the physical file ‘/var/opt/sqlserver/testdatabase.mdf’. env MSSQL_LOG_DIR="/var/opt/sqlserver" ` env MSSQL_DATA_DIR="/var/opt/sqlserver" ` env MSSQL_BACKUP_DIR="/var/opt/sqlserver" ` Quite a bit to type there, no? Do we really want to be typing that out every time we run a container?Īnd it gets even worse if we want to persist our databases from one container to another: – That opinion changed when I went to DockerCon in 2018 and had a chance to speak to some Docker Captains who told me that they used compose for everything!Īnd it makes sense, let’s have a look at spinning up one container running SQL Server 2019: – I used to think that Docker Compose was used solely to spin up multiple containers, in fact I blogged about doing just that here.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |