How to Install and Use Docker for Development on Arch Linux

How to Install and Use Docker for Development on Arch Linux

Docker has become a cornerstone of modern software development. With its lightweight containers and consistent environments, it makes developing, testing, and deploying applications easier than ever. If you’re using Arch Linux — a rolling-release distribution that’s popular among power users — you’ll find that installing and using Docker is relatively straightforward, but does require some attention to detail.

This guide walks you through installing Docker on Arch Linux, configuring it for development purposes, and using it effectively in your development workflow.


Why Use Docker on Arch Linux?

Arch Linux users often enjoy full control over their environments and software stacks, and Docker complements that by offering:

  • Environment consistency – Say goodbye to “works on my machine” problems.
  • Isolation – Run your application and its dependencies in separate containers.
  • Portability – Share containers across machines with ease.
  • Reproducibility – Build predictable development environments.

Arch Linux’s rolling release model ensures that you always have the latest Docker version, which is great for developers who want to stay up-to-date.


Step 1: Installing Docker on Arch Linux

1.1. Update Your System

Before installing any software, it’s a good idea to update your system:

sudo pacman -Syu

This ensures that your package database and installed packages are current.

1.2. Install Docker

Docker is available directly from the Arch Community repository. Install it using pacman:

sudo pacman -S docker

This will install the Docker Engine and CLI tools.


Step 2: Starting and Enabling Docker

2.1. Enable the Docker Daemon

To start Docker immediately and enable it at boot:

sudo systemctl start docker
sudo systemctl enable docker

To check the status of the Docker daemon:

systemctl status docker

If it’s running, you’re good to go.


Step 3: Using Docker Without sudo

By default, only the root user can run Docker commands. To use Docker as a non-root user, add your user to the docker group:

sudo usermod -aG docker $USER

You must log out and log back in (or reboot) for the group change to take effect.

To confirm it’s working, run:

docker run hello-world

If it prints a welcome message, Docker is working correctly.


Step 4: Basic Docker Concepts

Before diving into development, let’s quickly review the core concepts:

  • Image – A snapshot of a file system and environment.
  • Container – A running instance of an image.
  • Dockerfile – Script with instructions to build an image.
  • Volume – Persistent data storage outside the container.
  • Network – Connectivity between containers and the host system.

Step 5: Setting Up a Development Environment with Docker

Let’s create a simple containerized development environment for a Node.js application as an example.

5.1. Create a Project Directory

mkdir ~/projects/docker-node-app
cd ~/projects/docker-node-app

5.2. Add a Sample app.js

// app.js
const http = require('http');
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello from Docker on Arch Linux!\n');
});

server.listen(port, () => {
  console.log(`Server running at http://localhost:${port}/`);
});

5.3. Add a package.json

{
  "name": "docker-node-app",
  "version": "1.0.0",
  "main": "app.js",
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {}
}

5.4. Write a Dockerfile

# Use official Node.js image
FROM node:20-alpine

# Set working directory
WORKDIR /usr/src/app

# Copy files
COPY package*.json ./
RUN npm install

COPY . .

# Expose port and start app
EXPOSE 3000
CMD ["npm", "start"]

5.5. Build the Docker Image

docker build -t my-node-app .

5.6. Run the Container

docker run -p 3000:3000 my-node-app

Now open your browser and navigate to http://localhost:3000 — you should see the “Hello from Docker on Arch Linux!” message.


Step 6: Managing Volumes for Persistent Development

To persist code changes and allow hot reloading, you can mount your local directory into the container:

docker run -v $(pwd):/usr/src/app -p 3000:3000 my-node-app

This way, changes made on the host are immediately reflected inside the container.

For real-world development, tools like nodemon are useful for auto-restarting your app:

npm install --save-dev nodemon

Update your Dockerfile or command accordingly to run nodemon instead of node.


Step 7: Docker Compose for Multi-Service Development

If your app depends on other services (like a database), Docker Compose can simplify managing everything.

7.1. Install Docker Compose

Docker Compose V2 is included with the Docker package on Arch Linux. You can run it using:

docker compose version

Note: no hyphen in docker compose for V2.

7.2. Create a docker-compose.yml

version: '3.8'
services:
  app:
    build: .
    ports:
      - "3000:3000"
    volumes:
      - .:/usr/src/app
    command: npm start

7.3. Start Your Environment

docker compose up --build

Now you’ve got a managed development environment, all defined in a single YAML file.


Step 8: Tips for Efficient Docker Usage in Development

  • Use .dockerignore to avoid copying unnecessary files into your image:

    node_modules
    .git
    
  • Keep images lightweight – Use Alpine-based images and multi-stage builds.

  • Clean up regularly – Remove unused containers, images, and volumes:

    docker system prune -a
    
  • Tag your images – Use semantic tags to differentiate builds:

    docker build -t my-node-app:dev .
    

Step 9: Troubleshooting Common Issues

  • Permission denied when using Docker – Make sure your user is in the docker group and you’ve re-logged.
  • Port already in use – Check with ss -tulwn and stop conflicting services.
  • Slow builds – Use layer caching and minimize Dockerfile steps.
  • Cannot connect to Docker daemon – Confirm the Docker service is running with systemctl status docker.

Conclusion

Docker offers a powerful and flexible platform for developing applications, especially on Arch Linux where users value control and customization. From installation to creating a full-fledged development environment, Docker integrates smoothly with your workflow and brings consistency across systems.

Whether you’re building a simple API or a microservice-based architecture, Docker helps reduce complexity and increase productivity. With tools like Docker Compose, you can go from writing code to deploying multi-service applications without leaving the command line.

By mastering Docker on Arch Linux, you not only improve your development process but also gain skills that are highly relevant in modern DevOps and software engineering roles.


If you’d like to expand this setup further, you can explore:

  • Integrating with CI/CD tools like GitHub Actions or GitLab CI.
  • Setting up container orchestration with Kubernetes (Minikube or Kind).
  • Using private registries for your images.
  • Managing Docker secrets and environment variables securely.