<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: kanpachioishi</title>
    <description>The latest articles on DEV Community by kanpachioishi (@kanpachioishi).</description>
    <link>https://dev.to/kanpachioishi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3846228%2Fae71b124-07a7-40a7-af6d-3e13acf68ccc.jpeg</url>
      <title>DEV Community: kanpachioishi</title>
      <link>https://dev.to/kanpachioishi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kanpachioishi"/>
    <language>en</language>
    <item>
      <title>Set Up a LaTeX Environment in 10 Minutes with Docker on Windows</title>
      <dc:creator>kanpachioishi</dc:creator>
      <pubDate>Sat, 28 Mar 2026 02:05:35 +0000</pubDate>
      <link>https://dev.to/kanpachioishi/set-up-a-latex-environment-in-10-minutes-with-docker-on-windows-131c</link>
      <guid>https://dev.to/kanpachioishi/set-up-a-latex-environment-in-10-minutes-with-docker-on-windows-131c</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Ever tried to set up LaTeX and got stuck before writing a single document?&lt;/p&gt;

&lt;p&gt;When you install TeX Live directly, you run into path issues, version mismatches, and confusing configuration files. On top of that, the installation itself can take a very long time on Windows.&lt;/p&gt;

&lt;p&gt;In this guide, I'll show you how to &lt;strong&gt;set up a LaTeX environment using Docker&lt;/strong&gt; — and it only takes about 10 minutes.&lt;/p&gt;

&lt;p&gt;Why Docker?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fast&lt;/strong&gt; — In my experience, it took only about &lt;strong&gt;10 minutes&lt;/strong&gt; from start to finish&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simple&lt;/strong&gt; — Just a few commands. No path configuration or version management headaches&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reproducible&lt;/strong&gt; — Anyone can recreate the exact same environment. Easy to start over if something goes wrong&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clean&lt;/strong&gt; — No massive TeX Live installation on your system. Everything stays inside the Docker container&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't worry if you've never used Docker before. Just follow the steps in this guide, and you'll be compiling LaTeX documents in no time.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This guide is based on my actual experience setting up LaTeX on a freshly reset Windows PC. I've included the gotchas and errors I encountered along the way, so hopefully you won't have to struggle with the same issues.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OS&lt;/strong&gt;: Windows 10 (version 2004 or later) or Windows 11&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RAM&lt;/strong&gt;: 8 GB or more recommended&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage&lt;/strong&gt;: At least 5 GB of free space&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's all you need.&lt;/p&gt;




&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;There are three main steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Enable WSL2 (installs Ubuntu)
2. Install Docker on Ubuntu
3. Pull the LaTeX Docker image and start using it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything is done via the command line. No GUI installers needed.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Enable WSL2
&lt;/h2&gt;

&lt;p&gt;What is WSL2? How is it different from WSL?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WSL (Windows Subsystem for Linux)&lt;/strong&gt; lets you run Linux on Windows. WSL2 is the second version.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;WSL1&lt;/th&gt;
&lt;th&gt;WSL2&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;How it works&lt;/td&gt;
&lt;td&gt;Translates Linux calls to Windows&lt;/td&gt;
&lt;td&gt;Runs a real Linux kernel in a lightweight VM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;Fast file I/O, but limited compatibility&lt;/td&gt;
&lt;td&gt;Near-native Linux performance, Docker support&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Docker&lt;/td&gt;
&lt;td&gt;Not supported&lt;/td&gt;
&lt;td&gt;Supported&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Docker requires WSL2.&lt;/strong&gt; When you run &lt;code&gt;wsl --install&lt;/code&gt;, it automatically installs WSL2, so you don't need to worry about choosing.&lt;/p&gt;

&lt;h3&gt;
  
  
  1-1. Open PowerShell as Administrator
&lt;/h3&gt;

&lt;p&gt;Search for "PowerShell" in the Start menu and select &lt;strong&gt;"Run as administrator"&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  1-2. Install WSL2
&lt;/h3&gt;

&lt;p&gt;Run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--install&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This enables WSL2 and installs Ubuntu in one step.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If WSL2 is already installed, you'll see a message saying so. Just move on to the next step.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Getting "WSL install may be corrupted" error?&lt;/p&gt;

&lt;p&gt;When I tried this on a freshly reset PC, I got a "WSL install may be corrupted" error after running &lt;code&gt;wsl --install&lt;/code&gt;. Sometimes it appeared right away, sometimes after about a minute — so don't panic if nothing happens for a bit.&lt;/p&gt;

&lt;p&gt;The message says "Press any key to start WSL repair", but &lt;strong&gt;it times out after 60 seconds&lt;/strong&gt;. Press a key as soon as you see the message.&lt;/p&gt;

&lt;p&gt;After the repair completes, run &lt;code&gt;wsl --install&lt;/code&gt; again and it should work fine.&lt;/p&gt;

&lt;h3&gt;
  
  
  1-3. Set Up Ubuntu
&lt;/h3&gt;

&lt;p&gt;After installation, you'll be prompted to create a username and password. You can do this in PowerShell, but since we'll be working in Ubuntu from here on, &lt;strong&gt;you can close PowerShell&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Search for "Ubuntu" in the Start menu and open it. You'll be asked to set a username and password. Choose whatever you like (this is for Linux, separate from your Windows credentials).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Your password won't show on screen as you type&lt;/strong&gt; — not even &lt;code&gt;***&lt;/code&gt;. This is normal Linux security behavior. Just type your password and press Enter. You'll be asked to confirm it by entering it again.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Step 2: Install Docker on Ubuntu
&lt;/h2&gt;

&lt;p&gt;From here, work in the &lt;strong&gt;Ubuntu terminal&lt;/strong&gt;. Open "Ubuntu" from the Start menu.&lt;/p&gt;

&lt;h3&gt;
  
  
  2-1. Update Packages
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What does "sudo" mean?&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo&lt;/code&gt; means "run this command as administrator." You'll need it for installing software and making system changes. When prompted, enter the password you set in Step 1-3.&lt;/p&gt;

&lt;h3&gt;
  
  
  2-2. Install Docker
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; docker.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2-3. Allow Your User to Run Docker Without sudo
&lt;/h3&gt;

&lt;p&gt;By default, you need &lt;code&gt;sudo&lt;/code&gt; for every Docker command. Fix that with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; docker &lt;span class="nv"&gt;$USER&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What does this command do?&lt;/p&gt;

&lt;p&gt;&lt;code&gt;usermod -aG docker $USER&lt;/code&gt; adds your current user to the &lt;code&gt;docker&lt;/code&gt; group. Members of this group can run Docker commands without &lt;code&gt;sudo&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Close the Ubuntu window and reopen it&lt;/strong&gt; to apply the change.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I forgot to do this and got a &lt;code&gt;permission denied&lt;/code&gt; error when running &lt;code&gt;docker pull&lt;/code&gt;. Don't skip this step!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2-4. Verify Docker Is Working
&lt;/h3&gt;

&lt;p&gt;After reopening Ubuntu, check the Docker version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you see a version number, you're good.&lt;/p&gt;

&lt;p&gt;If the Docker daemon isn't running, start it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;service docker start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 3: Pull the LaTeX Docker Image
&lt;/h2&gt;

&lt;p&gt;Still in the Ubuntu terminal.&lt;/p&gt;

&lt;h3&gt;
  
  
  3-1. Download the Image
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker pull k1z3/texlive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;This takes 3-5 minutes on the first run&lt;/strong&gt; since it's downloading the full TeX Live environment. Grab a coffee while you wait.&lt;/p&gt;

&lt;h3&gt;
  
  
  3-2. Confirm the Download
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see &lt;code&gt;k1z3/texlive&lt;/code&gt; in the list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;REPOSITORY       TAG       IMAGE ID       CREATED        SIZE
k1z3/texlive     latest    xxxxxxxxxxxx   X months ago   X.XXGB
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 4: Set Up a Project Folder
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4-1. Create a Folder
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; ~/latex-project
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/latex-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to access this folder from Windows Explorer&lt;/p&gt;

&lt;p&gt;Type &lt;code&gt;\\wsl$\Ubuntu\home\YOUR_USERNAME\latex-project&lt;/code&gt; in the Explorer address bar. You can edit files using any Windows text editor (Notepad, VS Code, etc.).&lt;/p&gt;

&lt;h3&gt;
  
  
  4-2. Create the Required Files
&lt;/h3&gt;

&lt;p&gt;Create these two files in the folder. Use your preferred editor.&lt;/p&gt;

&lt;p&gt;Creating files from the Ubuntu terminal&lt;/p&gt;

&lt;p&gt;Copy and paste these commands:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create main.tex:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &amp;amp;lt&lt;span class="p"&gt;;&lt;/span&gt;&amp;amp;lt&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt; &amp;amp;gt&lt;span class="p"&gt;;&lt;/span&gt; main.tex
&lt;span class="se"&gt;\d&lt;/span&gt;ocumentclass&lt;span class="o"&gt;{&lt;/span&gt;article&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="se"&gt;\b&lt;/span&gt;egin&lt;span class="o"&gt;{&lt;/span&gt;document&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="se"&gt;\H&lt;/span&gt;uge &lt;span class="se"&gt;\L&lt;/span&gt;aTeX
&lt;span class="se"&gt;\e&lt;/span&gt;nd&lt;span class="o"&gt;{&lt;/span&gt;document&lt;span class="o"&gt;}&lt;/span&gt;
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Create .latexmkrc:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &amp;amp;lt&lt;span class="p"&gt;;&lt;/span&gt;&amp;amp;lt&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="s1"&gt;'EOF'&lt;/span&gt; &amp;amp;gt&lt;span class="p"&gt;;&lt;/span&gt; .latexmkrc
&lt;span class="nv"&gt;$latex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'uplatex'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$dvipdf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'dvipdfmx %O -o %D %S'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$pdf_mode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 3&lt;span class="p"&gt;;&lt;/span&gt;
EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;main.tex&lt;/strong&gt; (your document):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tex"&gt;&lt;code&gt;&lt;span class="k"&gt;\documentclass&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;article&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;\begin{document}&lt;/span&gt;
&lt;span class="k"&gt;\Huge&lt;/span&gt; &lt;span class="k"&gt;\LaTeX&lt;/span&gt;
&lt;span class="nt"&gt;\end{document}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;.latexmkrc&lt;/strong&gt; (build configuration):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight perl"&gt;&lt;code&gt;&lt;span class="nv"&gt;$latex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;uplatex&lt;/span&gt;&lt;span class="p"&gt;';&lt;/span&gt;
&lt;span class="nv"&gt;$dvipdf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dvipdfmx %O -o %D %S&lt;/span&gt;&lt;span class="p"&gt;';&lt;/span&gt;
&lt;span class="nv"&gt;$pdf_mode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What is .latexmkrc?&lt;/p&gt;

&lt;p&gt;Compiling LaTeX involves running multiple commands in sequence. &lt;code&gt;.latexmkrc&lt;/code&gt; is a configuration file that automates this process.&lt;/p&gt;

&lt;p&gt;This configuration specifies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;uplatex&lt;/code&gt; — The LaTeX engine to use&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dvipdfmx&lt;/code&gt; — Converts DVI format to PDF&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;$pdf_mode = 3&lt;/code&gt; — Uses the uplatex -&amp;gt; dvipdfmx pipeline to generate PDFs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your folder should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/latex-project/
├── main.tex
└── .latexmkrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 5: Compile and Generate a PDF
&lt;/h2&gt;

&lt;h3&gt;
  
  
  5-1. Make Sure You're in the Project Folder
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/latex-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5-2. Run the Compiler
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;:/texsrc"&lt;/span&gt; &lt;span class="nt"&gt;-w&lt;/span&gt; /texsrc k1z3/texlive latexmk main.tex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What does this command mean?&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;docker run&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Run a Docker container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--rm&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Automatically remove the container after it finishes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-v "$(pwd):/texsrc"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Mount the current folder to &lt;code&gt;/texsrc&lt;/code&gt; inside the container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-w /texsrc&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Set the working directory inside the container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;k1z3/texlive&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The Docker image to use&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;latexmk main.tex&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The command to compile &lt;code&gt;main.tex&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  5-3. Check the PDF
&lt;/h3&gt;

&lt;p&gt;If compilation succeeds, &lt;code&gt;main.pdf&lt;/code&gt; will be generated in your folder.&lt;/p&gt;

&lt;p&gt;Open &lt;code&gt;\\wsl$\Ubuntu\home\YOUR_USERNAME\latex-project&lt;/code&gt; in Windows Explorer and double-click &lt;code&gt;main.pdf&lt;/code&gt;. If you see "&lt;strong&gt;LaTeX&lt;/strong&gt;" displayed in large text, it worked!&lt;/p&gt;




&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  "docker: command not found"
&lt;/h3&gt;

&lt;p&gt;Docker isn't installed, or you haven't reopened Ubuntu after Step 2-3. Close and reopen the Ubuntu window, then try again.&lt;/p&gt;

&lt;h3&gt;
  
  
  "permission denied"
&lt;/h3&gt;

&lt;p&gt;You need to &lt;strong&gt;close and reopen Ubuntu&lt;/strong&gt; after running &lt;code&gt;sudo usermod -aG docker $USER&lt;/code&gt; in Step 2-3. The group change won't take effect until you do.&lt;/p&gt;

&lt;p&gt;If the error persists after reopening, check that the Docker daemon is running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;service docker start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  "Cannot connect to the Docker daemon"
&lt;/h3&gt;

&lt;p&gt;The Docker daemon isn't running. Start it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;service docker start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to auto-start Docker on WSL2 startup&lt;/p&gt;

&lt;p&gt;On WSL2, you may need to start the Docker daemon manually each time you open Ubuntu. To automate this, add the following to the end of your &lt;code&gt;~/.bashrc&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;service docker status 2&amp;amp;gt&lt;span class="p"&gt;;&lt;/span&gt;&amp;amp;amp&lt;span class="p"&gt;;&lt;/span&gt;1 | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s2"&gt;"is not running"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;service docker start &amp;amp;gt&lt;span class="p"&gt;;&lt;/span&gt; /dev/null 2&amp;amp;gt&lt;span class="p"&gt;;&lt;/span&gt;&amp;amp;amp&lt;span class="p"&gt;;&lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Note: You'll also need to configure passwordless &lt;code&gt;sudo&lt;/code&gt; for this to work silently. Search for "wsl2 docker auto start" for more details.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Here's what we did:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Enabled WSL2&lt;/strong&gt; (&lt;code&gt;wsl --install&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Installed Docker on Ubuntu&lt;/strong&gt; (&lt;code&gt;sudo apt install docker.io&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pulled the TeX Live image&lt;/strong&gt; (&lt;code&gt;docker pull k1z3/texlive&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Created a project folder with .tex and config files&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Compiled with &lt;code&gt;docker run&lt;/code&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;No need to install Docker Desktop or any other GUI application. Everything is done from the command line.&lt;/p&gt;

&lt;p&gt;Once this environment is set up, all you need to do is write &lt;code&gt;.tex&lt;/code&gt; files and run a single command. Even if you get a new PC, just install WSL2 and Docker, and your environment is instantly recreated.&lt;/p&gt;

&lt;p&gt;Happy TeXing!&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/engine/install/ubuntu/" rel="noopener noreferrer"&gt;Docker Official — Install Docker on Ubuntu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/windows/wsl/install" rel="noopener noreferrer"&gt;WSL2 Official Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>docker</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
