Docker Setup and Your First Container
We explain how to install Docker Desktop and Docker Engine, run your first container, write a Dockerfile and set up a multi-service environment with docker compose.

For a Docker installation on Windows and macOS, download the Docker Desktop installer from docker.com; on Windows, WSL 2 must be enabled first. On Linux, Docker Engine is installed from the official repository. After installation, run the docker run hello-world command; if you see the welcome message, Docker is working. For multi-service projects, docker compose is used.
What Is Docker and What Is It Used For?
Docker is a platform that packages an application with everything it needs and runs it in isolated environments called containers. The application, its libraries and its settings are bundled into a single image; this image behaves the same wherever it is run.
In practice this means the "it worked on my machine" problem largely goes away. The developer's laptop, the test server and the production server all use the same image. A new team member can also bring the project up with a single command instead of hours of setup.
Containers are similar to virtual machines but much lighter. Each one does not carry its own operating system; it shares the host's kernel, so it starts in seconds and uses fewer resources.
| Concept | In short |
|---|---|
| Image | A read-only template of the application; built from a Dockerfile |
| Container | A running instance started from an image |
| Dockerfile | A text file describing how to build the image |
| Volume | A persistent data area that remains even if the container is deleted |
| Docker Hub | A public registry where ready-made images are stored |
| Docker Compose | A tool that manages multiple containers with a single file |
Requirements Before Installing
Docker Desktop runs a small virtual environment in the background, so your computer's virtualization support must be turned on. It is on by default on most new computers; if not, you need to enable the Intel VT-x or AMD-V option in the BIOS/UEFI settings.
On Windows, Docker Desktop runs Linux containers on WSL 2. If WSL is not installed, install it first; we described the steps in detail in our WSL installation guide.
- Memory: If several containers will run at the same time, at least 8 GB of RAM gives comfortable working room.
- Disk space: Images accumulate over time; set aside a few tens of GB of free space.
- License: Docker Desktop is free for personal use, education and small businesses below a certain size; larger organizations need a paid subscription. Check the current terms at docker.com.
wsl --install
# After installation, restart the computer, then check
wsl --statusDocker Desktop on Windows and macOS
Docker Desktop offers Docker Engine, the command-line tool, Docker Compose and a visual management dashboard in a single package. Download the installer from the official site and install it with the default settings.
During installation on Windows, make sure the Use WSL 2 instead of Hyper-V option is checked. On macOS, choose the version that matches your processor: Apple Silicon (M series) or Intel. Start the app after installation; once the whale icon in the menu bar or taskbar settles, Docker is ready.
winget install -e --id Docker.DockerDesktopInstalling Docker Engine on Linux
On Linux, Docker runs directly as Docker Engine without Docker Desktop; this is also the standard method for servers. The most reliable path is to follow the distribution-specific repository setup in the official documentation. For development machines, Docker's official convenience script does the same job in one go.
If you add your user to the docker group after installation, you don't need to put sudo in front of every command. Because this group grants near-root privileges, add only users you trust.
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# To use without sudo
sudo usermod -aG docker $USER
newgrp docker
# Start the service at boot
sudo systemctl enable --now dockerVerifying the Installation
The verification commands are the same whichever operating system you use. The hello-world image is downloaded from Docker Hub, run, prints an explanation to the screen and exits. If you see this output, the client, the engine and the image download chain are all working properly.
docker --version
docker compose version
docker run hello-worldRunning Your First Container
Let's continue with a real example: start nginx, a lightweight web server, as a container and open it in the browser. The -d flag runs the container in the background, and -p 8080:80 maps port 8080 on your computer to port 80 in the container.
After running the command, open http://localhost:8080 in the browser; you should see the nginx welcome page. The other commands below let you monitor the container, get inside it and clean it up.
docker run -d -p 8080:80 --name web nginx
# Running containers
docker ps
# Follow the logs
docker logs web
# Open a shell inside the container
docker exec -it web sh
# Durdur ve sil
docker stop web
docker rm web
# Downloaded images
docker imagesServing your own files
To mount HTML files from a folder into the container, use a bind mount. The command below mounts your current folder read-only to nginx's web root; when you edit the file and refresh the page, you see the change immediately.
docker run -d -p 8080:80 -v "$(pwd)":/usr/share/nginx/html:ro --name site nginxBuilding your own image
To turn a Node.js application into an image, add a file named Dockerfile to the project root. Copying the package files and installing dependencies first prevents that layer from being rebuilt when the code changes and speeds up the build.
FROM node:lts-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
EXPOSE 3000
CMD ["npm", "start"]docker build -t uygulamam .
docker run -d -p 3000:3000 uygulamamMultiple Services with Docker Compose
Real projects usually consist of several parts: a web server, a database, maybe a cache. Instead of starting each one with separate docker run commands, you define them all in a single compose.yaml file with Docker Compose.
The example below starts an nginx web server and a MariaDB database together. Because the database files are kept in a named volume, the data survives even if the container is deleted. The version line seen in older examples is no longer required.
services:
web:
image: nginx:alpine
ports:
- "8080:80"
volumes:
- ./site:/usr/share/nginx/html:ro
depends_on:
- db
db:
image: mariadb:lts
environment:
MARIADB_ROOT_PASSWORD: degistirin
MARIADB_DATABASE: uygulama
volumes:
- db-veri:/var/lib/mysql
volumes:
db-veri:docker compose up -d
docker compose ps
docker compose logs -f
docker compose down
# Volume'larla birlikte sil (veriler gider)
docker compose down -vCommon Errors and Fixes
Problems encountered during a Docker installation are mostly about virtualization, permissions and port conflicts. If images and stopped containers fill the disk over time, docker system prune cleans up unused resources; the command asks for confirmation before deleting.
- WSL 2 / virtualization error: Enable virtualization in the BIOS, update WSL with wsl --update and restart the computer.
- port is already allocated: The port you chose is used by another application. Choose a different port such as -p 8081:80 or close the conflicting application.
- permission denied ... docker.sock: On Linux, your user is not in the docker group; after running usermod, log out and back in.
- Cannot connect to the Docker daemon: Docker Desktop is closed or, on Linux, the service is not running; start it with sudo systemctl start docker.
- Image architecture warning on Mac: Some images are published only for x86. If possible, choose a tag with ARM support.
What Does Docker Bring to Web Projects?
Docker makes the development, test and production environments of a web project identical. Running a project with PHP and a database in containers instead of single-machine packages like a XAMPP installation reduces surprises caused by version differences. To manage PHP dependencies inside a container, see also our Composer installation guide.
Reproducible environments make it easier for speed and performance improvements to give the same result in production. This consistency also matters for integrated solutions where multiple systems work together and for a growing e-commerce platform.
For other container and server content, take a look at our docker tag page.
Frequently Asked Questions
01What is the difference between Docker and a virtual machine?
A virtual machine carries its own operating system, takes up gigabytes of space and starts in minutes. A container shares the host's kernel, can stay at the megabyte level and starts in seconds; in return, its isolation is not as strong as a virtual machine's.
02Can I use Docker on Windows without Docker Desktop?
Yes. You can install Docker Engine directly on a Linux distribution inside WSL 2. This method gives flexibility on licensing, but you give up conveniences such as the visual dashboard and automatic updates.
03Will my data be lost when a container is deleted?
Data written inside a container is lost when the container is deleted. Attach data that must persist, such as database files, outside the container with a volume or bind mount; and remember that the docker compose down -v command also deletes volumes.
04Is Docker used on production servers?
Yes, many applications run in production as containers. However, backups, updates, log monitoring and security settings must be planned separately in production; an exact copy of a development machine setup is not enough.
Once you have installed Docker and run your first container, you have moved to a reproducible setup in which you can bring your projects up the same way on every machine. If you want custom software for your business that is developed and easy to maintain in this setup, explore Aurora Yazılım's custom software solutions or get in touch with us.


