{"id":4994,"date":"2026-08-30T02:00:39","date_gmt":"2026-08-29T17:00:39","guid":{"rendered":"https:\/\/donguri3.net\/server-tech\/localllm-gemma3-wsl2-docker-compose-2\/"},"modified":"2026-08-30T02:00:40","modified_gmt":"2026-08-29T17:00:40","slug":"localllm-gemma3-wsl2-docker-compose","status":"publish","type":"post","link":"https:\/\/donguri3.net\/en\/server-tech\/ai-local-llm\/localllm-gemma3-wsl2-docker-compose\/","title":{"rendered":"Setting Up a Local LLM Environment: How to Deploy ollama, open-webui, and gemma3 Using WSL2 \u00d7 Docker Desktop \u00d7 NVIDIA Container Toolkit"},"content":{"rendered":"<p>In recent years, the demand for LLMs (Large Language Models) has rapidly grown, drawing significant attention not only to cloud-based deployments but also to local environments. In this article, we explain the step-by-step procedure for setting up ollama, open-webui, and gemma3 locally on a Windows environment using WSL2, Docker Desktop (docker-compose), and the NVIDIA Container Toolkit.<br \/>Building a local environment offers advantages such as ensuring data privacy and enabling low-latency inference processing.<\/p>\n<h2>Environment Preparation<\/h2>\n<h3>Required Hardware and Software<\/h3>\n<ul>\n<li><strong>OS:<\/strong> Windows 10\/11<\/li>\n<li><strong>WSL2:<\/strong> Ubuntu 22.04 or later (e.g., Ubuntu 24.04)<\/li>\n<li><strong>Docker Desktop:<\/strong> Latest version (with WSL2 integration enabled)<\/li>\n<li><strong>NVIDIA GPU:<\/strong> For GPU-equipped PCs, install the NVIDIA Container Toolkit to utilize the GPU<\/li>\n<li><strong>Other:<\/strong> Internet connection, sufficient RAM (capacity depending on the LLM model size)<\/li>\n<\/ul>\n<h3>Prerequisites<\/h3>\n<ol>\n<li>\n<p><strong>Installing WSL2<\/strong><br \/>Run the following command in PowerShell (Administrator mode) to install WSL2 and the Ubuntu distribution.<\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\">\n<pre>wsl --install -d Ubuntu-24.04<\/pre>\n<\/div>\n<\/div>\n<\/li>\n<li>\n<p><strong>Installing Docker Desktop<\/strong><br \/>Download and install Docker Desktop on Windows from the <a href=\"https:\/\/docs.docker.com\/desktop\/setup\/install\/windows-install\/\">official website<\/a>, and enable WSL2 integration.<br \/>\nIf you encounter the following error when running <code>docker-compose ps<\/code> in your WSL2 environment, try restarting Docker Desktop. For some reason, this fixes it.<br \/>\n<code>The command 'docker-compose' could not be found in this WSL 2 distro. We recommend to activate the WSL integration in Docker Desktop settings. For details about using Docker Desktop with WSL 2, visit: https:\/\/docs.docker.com\/go\/wsl2\/<br \/>\n<\/code>Reference: <a href=\"https:\/\/zenn.dev\/masa20210102\/articles\/48775049baf8c4\">How to resolve &#8220;The command &#8216;docker-compose&#8217;\uff5e&#8221; even when WSL integration is enabled in Docker Desktop<\/a> (Japanese)<\/p>\n<\/li>\n<li>\n<p><strong>Installing the NVIDIA Container Toolkit (when using a GPU)<\/strong><br \/>Perform the installation on Ubuntu on WSL2 using the following steps.<\/p>\n<pre># Install required packages\nsudo apt-get update &amp;&amp; sudo apt-get install -y curl gnupg ca-certificates\n\n# Add NVIDIA's GPG key and repository\ncurl -fsSL https:\/\/nvidia.github.io\/libnvidia-container\/gpgkey | sudo gpg --dearmor -o \/usr\/share\/keyrings\/nvidia-container-toolkit-keyring.gpg\ncurl -s -L https:\/\/nvidia.github.io\/libnvidia-container\/stable\/deb\/nvidia-container-toolkit.list \\\n  | sed 's#deb https:\/\/#deb [signed-by=\/usr\/share\/keyrings\/nvidia-container-toolkit-keyring.gpg] https:\/\/#g' \\\n  | sudo tee \/etc\/apt\/sources.list.d\/nvidia-container-toolkit.list\nsudo apt-get update\nsudo apt-get install -y nvidia-container-toolkit\n\n# Configure Docker to use the NVIDIA runtime\nsudo nvidia-ctk runtime configure --runtime=docker\nsudo systemctl restart docker\n<\/pre>\n<\/li>\n<\/ol>\n<h2>Installing and Configuring Each Tool (Verification)<\/h2>\n<p>Here, we verify the operation of each tool. If you prefer, you can skip ahead to launching via docker-compose.<\/p>\n<h3>Introducing ollama<\/h3>\n<p>ollama is a tool for running LLM inference locally.<br \/>Below is an example of starting an ollama container without GPU support.<\/p>\n<pre>docker run -d \\\n  -v ollama:\/root\/.ollama \\\n  -p 11434:11434 \\\n  --name ollama \\\n  ollama\/ollama:0.6.2<\/pre>\n<p>Below is an example of starting a GPU-enabled ollama container.<\/p>\n<pre>docker run -d <span style=\"color: #00ff00;\">--gpus=all<\/span> \\\n  -v ollama:\/root\/.ollama \\\n  -p 11434:11434 \\\n  --name ollama \\\n  ollama\/ollama:0.6.2<\/pre>\n<p><em>Tips:<\/em><\/p>\n<ul>\n<li>Mount a volume using the <code>-v<\/code> option to persist model data and other files.<\/li>\n<li>Use <code>--gpus=all<\/code> to configure GPU utilization.<\/li>\n<li>Initial model downloads and initial loading may take some time, so please allow yourself plenty of time.<\/li>\n<li>Here, ollama version 0.6.2 is used.<\/li>\n<\/ul>\n<h3>Using gemma3<\/h3>\n<p>gemma3 is one of the LLM models compatible with ollama.<br \/>You can start gemma3 inference by running the following command inside the ollama container.<br \/>\ngemma3 is available in model sizes with 1B \/ 4B \/ 12B \/ 27B parameters.<br \/>\ngemma3:1b is sufficient for operational verification, so we will use that. Those with abundant PC resources are welcome to try gemma3:4b, gemma3:12b, or gemma3:27b.<\/p>\n<pre>docker exec -it ollama ollama run gemma3:1b<\/pre>\n<p><em>Tips:<\/em><\/p>\n<ul>\n<li>Since downloading the model may require several gigabytes of data, please perform this in a stable network environment.<\/li>\n<li>It has been reported that the initial launch is &#8220;slow on first load,&#8221; so you may want to consider configuring caching or resident settings (e.g., adjusting <code>OLLAMA_KEEP_ALIVE<\/code>).<\/li>\n<li>On an environment with an NVIDIA GeForce RTX 3060 (12GB GPU memory) and 32GB system memory, gemma3:12b was the limit. Continuing to use 12b caused overheating and a Blue Screen of Death, so 4b seems like the safer choice for this specification.<\/li>\n<\/ul>\n<h2>Startup Management with docker-compose<\/h2>\n<p>Here is how to use docker-compose to simultaneously start and manage multiple containers (ollama, open-webui, etc.).<br \/>Below is an example of a sample <code>docker-compose.yml<\/code> file.<\/p>\n<pre>services:\n  ollama:\n    image: ollama\/ollama\n    container_name: ollama\n    ports:\n      - \"11434:11434\"\n    volumes:\n      - .\/ollama_data:\/root\/.ollama\n    deploy:\n      resources:\n        reservations:\n          devices:\n            - driver: nvidia\n              count: all\n              capabilities: [gpu]\n\n  open-webui:\n    image: ghcr.io\/open-webui\/open-webui:main\n    container_name: open-webui\n    ports:\n      - \"3000:8080\"\n    volumes:\n      - .\/open-webui_data:\/app\/backend\/data\n    extra_hosts:\n      - \"host.docker.internal:host-gateway\"\n    depends_on:\n      - ollama\n<\/pre>\n<p><em>Tips:<\/em><\/p>\n<ul>\n<li>If you encounter the error message <code>WARN[0000] \/path\/to\/docker-compose.yml: `version` is obsolete<\/code>, please delete the version line in your docker-compose file. The version line has been omitted in the example above. Apparently, version is no longer required in Docker Compose V2.<br \/>\nReference: <a href=\"https:\/\/zenn.dev\/harpseal\/articles\/8dc2602ffe3365\">[Docker Compose] How to resolve the warning `version` is obsolete<\/a> (Japanese)<\/li>\n<li>If you encounter the error message <code>Error saving credentials: error storing credentials - err: fork\/exec \/usr\/bin\/docker-credential-desktop.exe: exec format error, out: ``<\/code>, reinstalling Docker Desktop will fix it.<br \/>\nReference: <a href=\"https:\/\/github.com\/docker\/for-win\/issues\/14039\">Error saving credentials: error storing credentials \u2013 err: fork\/exec \/usr\/bin\/docker-credential-desktop.exe: exec format error, out: \u201c \u00b7 Issue #14039 \u00b7 docker\/for-win<\/a><\/li>\n<li>Configure <code>volumes<\/code> to persist data for each container in host folders.<\/li>\n<li>Use <code>depends_on<\/code> to explicitly state that open-webui depends on ollama.<\/li>\n<li>Adjust environment variables and additional settings as needed.<\/li>\n<\/ul>\n<h2>How to Use<\/h2>\n<p>Enter localhost:3000 in your browser, register an account, and the chat screen will appear.<br \/>\n<a href=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/eef7bf3496a44e9271d38060f6495614-e1742388246567.png\"><img decoding=\"async\" class=\"aligncenter wp-image-957 size-large\" src=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/eef7bf3496a44e9271d38060f6495614-e1742388246567-1024x796.png\" alt=\"Local LLM\" width=\"1024\" height=\"796\" srcset=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/eef7bf3496a44e9271d38060f6495614-e1742388246567-1024x796.png 1024w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/eef7bf3496a44e9271d38060f6495614-e1742388246567-300x233.png 300w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/eef7bf3496a44e9271d38060f6495614-e1742388246567-768x597.png 768w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/eef7bf3496a44e9271d38060f6495614-e1742388246567.png 1338w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a>It&#8217;s telling lies to me&#8230;<br \/>\n<a href=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1b20081e9a83b57dd0f54ba96ead759c.png\"><img decoding=\"async\" class=\"aligncenter wp-image-958 size-full\" src=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1b20081e9a83b57dd0f54ba96ead759c.png\" alt=\"Local LLM GPU Usage\" width=\"1022\" height=\"771\" srcset=\"https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1b20081e9a83b57dd0f54ba96ead759c.png 1022w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1b20081e9a83b57dd0f54ba96ead759c-300x226.png 300w, https:\/\/donguri3.net\/wp-content\/uploads\/2025\/03\/1b20081e9a83b57dd0f54ba96ead759c-768x579.png 768w\" sizes=\"(max-width: 1022px) 100vw, 1022px\" \/><\/a><\/p>\n<p>It also looks like the GPU is being utilized.<\/p>\n<h2>References<\/h2>\n<ul>\n<li><a href=\"https:\/\/zenn.dev\/takoyaki3\/articles\/f181f455ac21f7\">Running Gemma3 with Docker in a Local Environment (Ollama+OpenWebUI)<\/a> (Japanese)<\/li>\n<li><a href=\"https:\/\/zenn.dev\/toki_mwc\/articles\/d1ebbd634ff488\">Setting Up Ollama on Windows Using WSL2 and Docker<\/a> (Japanese)<\/li>\n<li><a href=\"https:\/\/docs.docker.com\/desktop\/setup\/install\/windows-install\/\">Windows | Docker Docs<\/a><\/li>\n<li><a href=\"https:\/\/docs.nvidia.com\/datacenter\/cloud-native\/container-toolkit\/latest\/install-guide.html\">Installing the NVIDIA Container Toolkit \u2014 NVIDIA Container Toolkit<\/a><\/li>\n<li><a href=\"https:\/\/zenn.dev\/masa20210102\/articles\/48775049baf8c4\">How to resolve &#8220;The command &#8216;docker-compose&#8217;\uff5e&#8221; even when WSL integration is enabled in Docker Desktop<\/a> (Japanese)<\/li>\n<li><a href=\"https:\/\/zenn.dev\/harpseal\/articles\/8dc2602ffe3365\">[Docker Compose] How to resolve the warning `version` is obsolete<\/a> (Japanese)<\/li>\n<li><a href=\"https:\/\/github.com\/docker\/for-win\/issues\/14039\">Error saving credentials: error storing credentials \u2013 err: fork\/exec \/usr\/bin\/docker-credential-desktop.exe: exec format error, out: \u201c \u00b7 Issue #14039 \u00b7 docker\/for-win<\/a><\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>In this article, we explained how to deploy ollama, open-webui, and gemma3 to a local environment using Docker Desktop (docker-compose) and the NVIDIA Container Toolkit under a WSL2 environment.<br \/>We covered everything from installing each tool to managing multiple containers using docker-compose, complete with concrete command and configuration examples.<br \/>This makes local LLM operation straightforward, enabling rapid development and secure data management.<\/p>\n<p>Feel free to customize it to match your own environment and build an efficient LLM setup.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In recent years, the demand for LLMs (Large Language Models) has rapidly grown, drawing significant attention  [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":970,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/donguri3.net\/?p=955","footnotes":""},"categories":[1169],"tags":[18,19,51,52,100,365],"class_list":["post-4994","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai-local-llm","tag-docker","tag-docker-compose","tag-git","tag-https","tag-ubuntu-22-04","tag-wsl2","en-US"],"_links":{"self":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts\/4994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/comments?post=4994"}],"version-history":[{"count":1,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts\/4994\/revisions"}],"predecessor-version":[{"id":4997,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/posts\/4994\/revisions\/4997"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/media\/970"}],"wp:attachment":[{"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/media?parent=4994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/categories?post=4994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/donguri3.net\/wp-json\/wp\/v2\/tags?post=4994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}