Use the Docker CE template on your LWS KVM VPS

Procédure

The Docker CE template installs Docker CE, Docker Compose, and Buildx on your LWS KVM VPS, with no package to add manually. This guide shows you how to reinstall your server with this template, then use it day to day with Docker Compose. You will see how to launch a site, follow its logs, keep its data, update it, and expose it on the Internet.

Install Docker with the Docker CE template

  1. Access the management interface for the KVM VPS server

    Log in to your LWS customer area and open the Servers tab. Find your VPS, then click Manage to open its interface.

    Use the Docker CE template on your LWS KVM VPS
  2. Open the reinstallation tool

    In the left-hand side menu, click Reinstallation. The catalog of systems and applications is displayed.

    Use the Docker CE template on your LWS KVM VPS
  3. Select the Docker CE template

    In the applications section, under the Docker category, choose for example Docker CE ubuntu-24-04.

    Use the Docker CE template on your LWS KVM VPS
  4. Select your SSH key and start the reinstallation

    Under SSH keys to install (optional), check your SSH key. Then click Reinstall the server at the bottom right.

    Use the Docker CE template on your LWS KVM VPS
  5. Confirm the system reinstallation

    In the warning window, enter your server's exact name, then click the red Reinstallation button.

    Use the Docker CE template on your LWS KVM VPS
  6. Wait during deployment

    The system creates your environment with Docker CE, Docker Compose, and Buildx. The operation usually takes between 3 and 5 minutes.

    Use the Docker CE template on your LWS KVM VPS

Connect and verify the installation

  1. Retrieve the IP address and connect via SSH

    When the server switches back to ON with the Docker CE label, note its IPv4 address in the Server IPs block. Open a terminal on your machine and connect as root, replacing the example IP with yours.

    ⌨ Command
    ssh root@203.0.113.10
    Use the Docker CE template on your LWS KVM VPS
  2. Check that Docker works

    Display the Docker and Docker Compose versions. Then run the hello-world test container: it displays a message and then stops.

    ⌨ On the server
    docker --version
    docker compose version
    docker run --rm hello-world
    Expected result
    Hello from Docker!
    This message shows that your installation appears to be working correctly.

Use Docker day to day

  1. Create a project folder and a compose.yaml file

    A compose.yaml file describes your containers. Create a project folder with a subfolder for the site pages and a home page. Then create the compose.yaml file: it starts Nginx, publishes server port 8080 to container port 80, mounts the local folder read-only, and restarts the container unless manually stopped.

    ⌨ On the server
    mkdir -p /root/my-site/html
    cd /root/my-site
    echo '

    Hello from Docker

    ' > html/index.html nano compose.yaml
    📄 /root/my-site/compose.yaml
    services:
      web:
        image: nginx:stable
        ports:
          - "8080:80"
        volumes:
          - ./html:/usr/share/nginx/html:ro
        restart: unless-stopped
  2. Start the project

    From the project folder, start the services in the background. Docker downloads the image the first time, then creates the container. Then test the site's response from the server.

    ⌨ On the server
    cd /root/my-site
    docker compose up -d
    curl http://localhost:8080
    Expected result

    Hello from Docker

  3. View the containers and their logs

    List the project's containers to check their status. Then follow their logs live to spot an error or see the requests received. Exit the follow mode with Ctrl+C: the containers keep running.

    ⌨ On the server
    docker compose ps
    docker compose logs -f
  4. Keep your data with volumes

    The contents of a container disappear when it is removed. To keep data, store it in a volume. In the example, the html folder is mounted into the container: your pages remain on the server. For a database, use instead a named volume, declared in the compose.yaml file. The commands below list the volumes and show the location of one of them.

    ⌨ On the server
    docker volume ls
    docker volume inspect volume_name
  5. Update images

    To switch to a newer version of the image, download it then recreate the container. Docker only replaces the services whose image has changed. Your volumes are preserved.

    ⌨ On the server
    cd /root/my-site
    docker compose pull
    docker compose up -d
  6. Automatically restart when the server starts

    With restart: unless-stopped in the compose.yaml file, the container restarts after a server reboot. It remains stopped if you stopped it yourself. The Docker service starts automatically with the system: check it with the command below.

    ⌨ On the server
    systemctl is-enabled docker
    Expected result
    enabled
  7. Stop and clean up

    The first command stops and removes the project's containers, but keeps your files and volumes. The second removes stopped containers, unused networks, and orphaned images (untagged). Docker asks for confirmation before running it.

    ⌨ On the server
    docker compose down
    docker system prune
  8. Expose an application on the Internet

    The ports line in the compose.yaml file publishes a server port. With 8080:80, the site responds on port 8080 of the server IP, for example http://203.0.113.10:8080. If the firewall is active on your VPS, open this port in the Firewall menu of the KVM panel. To use a domain name such as example.com, point it to the server IP through your DNS manager.

    ⌨ Command
    curl http://203.0.113.10:8080
    Expected result

    Hello from Docker

Glossary

compose.yaml
File that describes a project's containers (image, ports, volumes, restart) and that Docker Compose reads to launch them.
Volume
Storage space kept outside the container, which makes it possible to retain data even if the container is deleted or recreated.
Image
Fixed template containing an application’s code and dependencies, from which Docker creates containers.
Container
Running instance of an image, isolated from the rest of the server.

Frequently asked questions

Do I need to install Docker Compose or Docker Buildx separately?

No. The Docker CE template includes the Docker CE engine as well as the Docker Compose and Docker Buildx extensions. They are usable as soon as the reinstallation is complete.

Why is my SSH key not present if I add it afterward?

SSH keys are injected into the root account only during system installation. If you add a key later, add it yourself in the ~/.ssh/authorized_keys file.

How do I expose my Docker application on the Internet?

Publish the port with the ports section of the compose.yaml file, for example 8080:80. If the firewall is active, also open this port in the Firewall menu of the KVM panel.

Where is the data from a volume stored?

For a named volume, Docker stores it on the server disk, under /var/lib/docker/volumes. The docker volume inspect command shows the exact location. For a folder mounted as ./html, the data remains in your project folder.

How do I view the logs of a container that does not start?

From the project folder, run docker compose ps -a to see each service's status, then docker compose logs service_name to read its error messages. An indentation mistake in the compose.yaml file is a common cause.

How do I start a container automatically when the server boots?

Add restart: unless-stopped to the service in the compose.yaml file, then run docker compose up -d again. The Docker service starts with the system and then restarts your containers.

What is the difference between a Docker image and a container?

An image is a fixed template that contains the code and its dependencies. The container is the running instance created from that image.

Does reinstalling my KVM VPS keep my snapshots?

No. Reinstallation overwrites the local disk and permanently deletes the data as well as the existing snapshots.

help.lws.net/a/7930
Was this article helpful?

Yes

No

Read 1 times

Thank you! Feel free to ask questions about our documentation if you would like more information, and help us improve it.

Similar articles

A question about this article?

Ask the LWS team and the community. Answers are published after moderation.

Ask the LWS team and its community a question

GDPR: Controller: LWS-Ligne Web Services. Purpose: moderation and public publication of your question, possible notification of an answer. Legal basis: consent (Art. 6(1)(a) GDPR). Email retention: 90 days after notification, 12 months maximum without an answer. To exercise your rights, see the GDPR section of our Terms and Conditions.