Docker - Part 1 - Intro & Installation
January 16, 2021
I was first introduced to Docker in one of my previous jobs and all I knew about it was that it allowed you to run programs on your machine without having to locally install dependencies required for it. I will be making multiple posts documenting what I learn about Docker.
What is Docker?
Docker is used for creating and managing containers.
A container is a package of the code and dependencies needed to run the program. No matter where it's running, it should always execute the same way.
You may be wondering "why not use virtual machines?". Well, having multiple machines on your computer can give the same use of allowing others to load up the same project, but this can cause slow performance and use up a lot of space on your computer. Docker doesn't require an OS in a container. You just need a configuration file to share (like a blueprint) so others can remake the container.
Docker Setup (Windows Version)
Since I have Windows 10 Pro, I wanted to give an overview of my experience installing Docker on Windows. There are also directions on how to install on Mac and Linux available here Opens in a new window . Make sure you check the system requirements for each OS.
Here's what I did:
- Enable Hyper-V and containers features (needed to create virtual machines).
Run PowerShell as administrator and enable Hyper-V:
> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
- Enable containers.
> Enable-WindowsOptionalFeature -Online -FeatureName containers –All
- Go to Docker's Get Started Opens in a new window page to download the Window's version of Docker Desktop.
When I clicked the installer, I kept all of the options checked (except the desktop shortcut which I didn't select).
I then had to restart my computer, when I logged back in, I got an error about WSL 2. I ran Docker Desktop from the start menu and changed the dependency on WSL 2 in settings so Docker could run properly. Then chose "Apply & Restart" at the bottom after I unchecked it.
docker in a command prompt (without admin access). You should see a list of commands to show that it is running.
- Docker Desktop installs Docker Engine and has a Daemon and CLI.
- I installed Docker Desktop on my computer since I had the requirements. If I didn't, I would've had to install Docker Toolbox instead.
- Whichever I used, Docker Engine would still have been installed.
- There is a Docker Playground Opens in a new window for practicing Docker in the browser.
- There are also tons of tutorials on the Docker site Opens in a new window to help you learn.
- If using VS Code you can use the extension Docker by Microsoft Opens in a new window to help.