How to run SQL server in a Docker container

Поділитися
Вставка
  • Опубліковано 1 жов 2024

КОМЕНТАРІ • 40

  • @djauryn852456753951
    @djauryn852456753951 2 роки тому +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

  • @alexanthony5642
    @alexanthony5642 2 роки тому +5

    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!

  • @boot-strapper
    @boot-strapper 3 роки тому +1

    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.

  • @akankshitadutta8842
    @akankshitadutta8842 2 роки тому +2

    Such an informative video explained to the finest detail! Thank you for sharing!

  • @theroboticscodedepot7736
    @theroboticscodedepot7736 2 роки тому

    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.

  • @erthill2269
    @erthill2269 2 роки тому +1

    Thank you! What's your vs code theme btw?

  • @emmanuel2842
    @emmanuel2842 4 роки тому +2

    trying to get my hands on Docker and i must say this video is simple and explanatory. Thanks

  • @YAHWEHROI
    @YAHWEHROI 2 роки тому +1

    Great Video. Thanks!

  • @prateekjha6862
    @prateekjha6862 2 роки тому +1

    Clear and concise video, good work

  • @antwnia2109
    @antwnia2109 2 роки тому +1

    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 роки тому +1

      Thanks for sharing!

    • @sidindian1982
      @sidindian1982 8 місяців тому

      @@LogRocket Sir ..We needed your Github repo file to test & run the code on your local machine

  • @joshuaabbott7134
    @joshuaabbott7134 4 роки тому +2

    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 роки тому +1

      @@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*

  • @MrAIProgrammer
    @MrAIProgrammer 3 роки тому

    What happens when you remove the container? will the data be still there?

  • @hamednaderi7675
    @hamednaderi7675 Рік тому

    Thank you!

  • @yassaminebenyamina
    @yassaminebenyamina 2 роки тому

    services.db.volumes must be a list I had this error whent I docker-comand ps

  • @franzsuarez5330
    @franzsuarez5330 4 роки тому +1

    Great video, and great explanation. Thanks, it helped me a lot.

  • @m1ckw
    @m1ckw 4 роки тому +1

    Nice! thank you.

  • @erthill2269
    @erthill2269 2 роки тому

    This video is so aesthetic, pleasure to watch

  • @recker2326
    @recker2326 3 роки тому

    Super awesome video man. Cheers!!!

  • @badrulhussain5545
    @badrulhussain5545 4 роки тому +1

    Hi would run sql server in docker on a production environment?

    • @briceayres
      @briceayres 4 роки тому +2

      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 UA-cam. Many thanks again for your reply.

  • @xx_hydrag123_lp_xx7
    @xx_hydrag123_lp_xx7 3 роки тому +1

    ist called mysql not mysequel btw :) sry but it was triggering me ...

  • @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.

  • @carvalho1990
    @carvalho1990 3 роки тому

    So where the dockerfile goes?

  • @isrcast01
    @isrcast01 4 роки тому

    Thank you! A question which theme do you use?

  • @gismoscherer
    @gismoscherer 3 роки тому

    Thx for sharing

  • @vinkalmann
    @vinkalmann 3 роки тому

    Very clear and useful, thank you!

  • @ashutoshsrivastava2275
    @ashutoshsrivastava2275 4 роки тому

    Thanks :)

  • @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.

  • @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!

  • @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 роки тому +1

      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.