How to run SQL server in a Docker container

  Рет қаралды 67,715

LogRocket

LogRocket

Күн бұрын

Curious about how to run SQL server in a Docker container? Watch this video to learn more.
Introduction & required technology -- 00:00
Initialize project -- 01:21
Create docker-compose YAML file -- 02:30
Spinning up the MSSQL docker image -- 06:00
Create NodeJS code to test the database -- 07:51
Initialize and hydrate database with a user record -- 12:21
Run NodeJS script and fetch a user record -- 16:03
Close running docker image -- 16:22
Try LogRocket for free: logrocket.com/?yt26
LogRocket is a frontend application monitoring solution that lets you replay problems as if they happened in your own browser. Instead of guessing why errors happen, or asking users for screenshots and log dumps, LogRocket lets you replay the session to quickly understand what went wrong. It works perfectly with any app, regardless of framework, and has plugins to log additional context from Redux, Vuex, and @ngrx/store.
In addition to logging Redux actions and state, LogRocket records console logs, JavaScript errors, stacktraces, network requests/responses with headers + bodies, browser metadata, and custom logs. It also instruments the DOM to record the HTML and CSS on the page, recreating pixel-perfect videos of even the most complex single-page apps.
Try it for free: logrocket.com/signup/

Пікірлер: 41
@alexanthony5642
@alexanthony5642 2 жыл бұрын
I love that you actively debugged so we don't have this image that you have to be perfect the first time and completely memorize everything... Even though I'm sure you work with this enough that you did memorize it all. But Awesome vid, super helpful! Thank you!
@emmanuel2842
@emmanuel2842 4 жыл бұрын
trying to get my hands on Docker and i must say this video is simple and explanatory. Thanks
@akankshitadutta8842
@akankshitadutta8842 2 жыл бұрын
Such an informative video explained to the finest detail! Thank you for sharing!
@vinkalmann
@vinkalmann 3 жыл бұрын
Very clear and useful, thank you!
@prateekjha6862
@prateekjha6862 2 жыл бұрын
Clear and concise video, good work
@franzsuarez5330
@franzsuarez5330 4 жыл бұрын
Great video, and great explanation. Thanks, it helped me a lot.
@erthill2269
@erthill2269 Жыл бұрын
This video is so aesthetic, pleasure to watch
@recker2326
@recker2326 2 жыл бұрын
Super awesome video man. Cheers!!!
@YAHWEHROI
@YAHWEHROI 2 жыл бұрын
Great Video. Thanks!
@m1ckw
@m1ckw 4 жыл бұрын
Nice! thank you.
@aashishchaubeyschannel2676
@aashishchaubeyschannel2676 4 жыл бұрын
Thank you team LogRocket, this was really helpful! Keep posting such videos. Also, since I'm new to the Docker ecosystem, I would like to learn some more stuff about making our app production-ready. Please make some content on that!
@isrcast01
@isrcast01 3 жыл бұрын
Thank you! A question which theme do you use?
@hamednaderi7675
@hamednaderi7675 Жыл бұрын
Thank you!
@gismoscherer
@gismoscherer 3 жыл бұрын
Thx for sharing
@antwnia2109
@antwnia2109 2 жыл бұрын
This tutorial was just God send. I was trying for 2 days to get SQL Server connected via docker on my Mac and kept getting errors for my password being disabled and being incorrect. Removed everything and with the exception of the await pool.close() - TypeError: Cannot read properties of undefined (reading 'close') everything else is A-mazing. Thank you!
@LogRocket
@LogRocket 2 жыл бұрын
Thanks for sharing!
@sidindian1982
@sidindian1982 6 ай бұрын
@@LogRocket Sir ..We needed your Github repo file to test & run the code on your local machine
@ashutoshsrivastava2275
@ashutoshsrivastava2275 3 жыл бұрын
Thanks :)
@federicomartinezescamilla9378
@federicomartinezescamilla9378 2 жыл бұрын
Thank you. I have a question: why when I down docker and then start again the created database for testing we made desapears, don't persist?
@erthill2269
@erthill2269 Жыл бұрын
Thank you! What's your vs code theme btw?
@MrAIProgrammer
@MrAIProgrammer 2 жыл бұрын
What happens when you remove the container? will the data be still there?
@joshuaabbott7134
@joshuaabbott7134 4 жыл бұрын
Thank for the tutorial! I am pretty new to docker... How can we persist the changes that we make to the database? After all the work of adding a table and inserting values, if the container is closed, all of that is lost. How can we instead keep those changes?
@nishanthraj8261
@nishanthraj8261 3 жыл бұрын
*Hi Joshua, you should create a docker volume and mount it to your sql server container. This will store your db data in your host machine. You don't have to worry even if you stop your containers.* *The data will be lost only if you delete that volume.* *Please find the path (google it) inside which the container stores the db data.* *Reference:* *docs.docker.com/storage/volumes/*
@nishanthraj8261
@nishanthraj8261 3 жыл бұрын
@@mohanreddy2309 Wish I could down vote your comment. Creating an image won't help him to save his data 😝
@mohanreddy2309
@mohanreddy2309 3 жыл бұрын
@@nishanthraj8261 👍 deleted
@nishanthraj8261
@nishanthraj8261 3 жыл бұрын
@@mohanreddy2309 Thank you!
@nishanthraj8261
@nishanthraj8261 3 жыл бұрын
*FYI* *docs.microsoft.com/en-us/sql/linux/sql-server-linux-docker-container-configure?view=sql-server-ver15&pivots=cs1-bash#persist* *This should do the trick*
@carvalho1990
@carvalho1990 3 жыл бұрын
So where the dockerfile goes?
@eduardot1979
@eduardot1979 3 жыл бұрын
thanks for the video well explained. If after you tutorial i want to take the image with the already create database and data to another PC, what i need to do?, how can i export the files? thanks.
@eugenevv
@eugenevv 3 жыл бұрын
Hi! Thanks for a video :) Would you be so kind to clarify please: You've created a new database table and inserted some data there. Then you're making a docker image down. What will be if you run it again and execute an sql query again? Will it still have the record in users table ?
@miklosnemeth8566
@miklosnemeth8566 3 жыл бұрын
A great question. The container itself has its own data storage within the container' disk space. You can stop and restart your container, you can insert records, its data remains. However, you must not _docker rm_ the container, otherwise your data is lost. Be aware that _docker run_ always creates a new container, so after you run a container once, next time simply start it. This behavior is perfect for experimenting and tutorial purposes. For production situations, you should read the excellent "Configure and customize SQL Server Docker containers" especially the Persist your data section covering data volumes and data containers. If your data is valuable, before removing a container make a backup of your data and when you have the new image, just restore the database from your backup.
@badrulhussain5545
@badrulhussain5545 4 жыл бұрын
Hi would run sql server in docker on a production environment?
@briceayres
@briceayres 4 жыл бұрын
Typically it is a bad idea to run your database in a docker container in production for a few reasons. Running a container has a performance overhead and typically the database is the first thing to become a bottleneck when it comes to performance....so running your database on “bare metal” (aka not in a virtual machine or container) will give you a small performance boost. Also, docker containers are meant for running stateless applications, but a database is not a stateless application. So if your container crashed and needed to be restarted, then that would be a problem (you could mount a volume to persist the data but even then you could have some problems with tables partially updating in a transaction). If you are running a simple application, on a single server, with a small server load and it’s a non critical application where downtime is acceptable...then you could run your database in a docker container. But I would instead recommend using a managed database service like Digital Ocean which can handle keeping your database running and frequently creates backups.
@badrulhussain5545
@badrulhussain5545 4 жыл бұрын
@@briceayres Thank you so much for your prompt reply Brice, you're a well experienced engineer. I was thinking on the same level and to keep it only on a dev environment. But I wasnt to sure about it as there are few people who do claim to run it on prod here on KZbin. Many thanks again for your reply.
@djauryn852456753951
@djauryn852456753951 2 жыл бұрын
In case someone has the error " Invalid object name 'users'", I found the SOLUTION: You need to set the "default_database_name" to the database you're using. to See which db is set, put this in your query: "SELECT sp.name , sp.default_database_name FROM sys.server_principals sp WHERE sp.name = SUSER_SNAME();" So if indeed it is set to the wrong db, put following inyur query: ALTER LOGIN sa WITH DEFAULT_DATABASE = testDb;` and excute: Now the settings are changed and you can put your original query back and the right answer as axpected will return
@xx_hydrag123_lp_xx7
@xx_hydrag123_lp_xx7 2 жыл бұрын
ist called mysql not mysequel btw :) sry but it was triggering me ...
@theroboticscodedepot7736
@theroboticscodedepot7736 Жыл бұрын
This seems pretty useless in a real life scenario where an application has multiple databases, multiple connections, lots of tables, stored procedures, triggers, and possibly millions of rows of data as well as needing to set numerous SQL server configuration options. And that is just the database portion of the application. Unless there is a way to do all that without spending weeks building the image file I can't see how Docker is useful.
@boot-strapper
@boot-strapper 3 жыл бұрын
pathetic that the container doesn't allow for creating a db on startup by default via env vars. I should not have to write a convoluted script to run on startup. Every other db container has this feature, wtf? This is why no one likes microsoft.
@yassaminebenyamina
@yassaminebenyamina 2 жыл бұрын
services.db.volumes must be a list I had this error whent I docker-comand ps
@kuttikrishnankodoth1463
@kuttikrishnankodoth1463 2 жыл бұрын
iam using mac, unfortunately this is not working and am getting opt/mssql/bin/sqlservr: Invalid mapping of address 0x40037d7000 in reserved address space below 0x400000000000. Possible causes: 1) the process (itself, or via a wrapper) starts-up its own running environment sets the stack size limit to unlimited via syscall setrlimit(2); 2) the process (itself, or via a wrapper) adjusts its own execution domain and flag the system its legacy personality via syscall personality(2); 3) sysadmin deliberately sets the system to run on legacy VA layout mode by adjusting a sysctl knob vm.legacy_va_layout.
.NET Docker Tutorial - SQL Server Docker [.NET Docker]
20:19
Coding Droplets
Рет қаралды 50 М.
Run SQL Server in Docker!
5:58
ScriptBytes
Рет қаралды 49 М.
Cat Corn?! 🙀 #cat #cute #catlover
00:54
Stocat
Рет қаралды 16 МЛН
Became invisible for one day!  #funny #wednesday #memes
00:25
Watch Me
Рет қаралды 59 МЛН
تجربة أغرب توصيلة شحن ضد القطع تماما
00:56
صدام العزي
Рет қаралды 58 МЛН
you need to learn Docker RIGHT NOW!! // Docker Containers 101
23:19
NetworkChuck
Рет қаралды 2,6 МЛН
How To Debug React Apps Like A Senior Developer
21:07
Web Dev Simplified
Рет қаралды 62 М.
What is Docker in 5 minutes
5:19
TechSquidTV
Рет қаралды 792 М.
Step by step - Run and Connect to SQL Server in Docker
17:15
Les Jackson
Рет қаралды 57 М.
How to Save Docker Data using Bind Mounts or Volumes
13:41
Database Star
Рет қаралды 29 М.
Docker Compose with .NET Core & SQL Server (Step by Step)
1:08:15
Les Jackson
Рет қаралды 102 М.
Deploy a .NET Core API with Docker (Step-by-Step)
36:17
Les Jackson
Рет қаралды 255 М.
Rate This Smartphone Cooler Set-up ⭐
0:10
Shakeuptech
Рет қаралды 1,6 МЛН
Как правильно выключать звук на телефоне?
0:17
Люди.Идеи, общественная организация
Рет қаралды 1,8 МЛН
Samsung laughing on iPhone #techbyakram
0:12
Tech by Akram
Рет қаралды 1,2 МЛН
ГОСЗАКУПОЧНЫЙ ПК за 10 тысяч рублей
36:28
Ремонтяш
Рет қаралды 548 М.