Managing Docker containers with Portainer on Ubuntu
Portainer gives Docker a browser-based control centre for starting, stopping, inspecting and organising workloads. It suits Ubuntu users who want the visibility of a graphical dashboard while retaining Docker’s portability across laptops, home servers and cloud instances. Portainer talks to the Docker Engine through its API, so the containers it manages remain ordinary Docker containers.
The setup has two layers: Docker performs the work, while Portainer supplies the interface. A sound installation protects the Docker socket, creates persistent storage for Portainer’s own data and provides a safe route for remote administration. These choices matter in Australia because home broadband, business VPS plans and regional cloud firewalls can behave differently from a local development computer.
This guide explains how to manage Docker containers with Portainer on Ubuntu, from installing the engine and control panel to deploying a Compose stack, setting resource limits and recovering from common faults. Commands assume a supported Ubuntu LTS release, such as Ubuntu 24.04 LTS, and a user with sudo access. Check the release and package support before applying them to a production server.
For readers in cities such as Sydney, Melbourne, Brisbane and Perth, network access needs local planning. A residential NBN or 5G connection may sit behind carrier-grade NAT, while a VPS in an Australian cloud region usually relies on both UFW and the provider’s security group. The following setup keeps those differences visible instead of assuming every Ubuntu machine has a public address.
Install Docker and Portainer on Ubuntu
Start by adding Docker’s official repository and the packages required on Ubuntu, including the Compose plugin:
sudo apt update
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
-o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-plugin
Complete the installation by enabling Docker at boot and adding the current account to the docker group:
sudo systemctl enable --now docker
sudo usermod -aG docker "$USER"
Log out and back in, or start a temporary session with newgrp docker. Test the engine with docker run hello-world and confirm the service with systemctl status docker. Membership of the docker group grants effective root-level access to the host, so only trusted accounts should receive it.
Install the free Portainer Community Edition as a Docker container:
sudo docker run -d \
--name portainer \
--restart=always \
-p 9443:9443 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:latest
The portainer_data volume retains Portainer’s settings and database. The Docker socket lets Portainer control the local engine, which also makes the access method a security concern. The latest tag is convenient for an initial test, while a production deployment should use a tested version recorded in a deployment script.
Connect securely to the Portainer web interface
Find the Ubuntu host’s addresses with hostname -I or ip -brief address. On the same network, open https://<server-ip>:9443 in a browser. Portainer initially uses a self-signed certificate, so the browser may display a certificate warning. Confirm that the address belongs to your server and install a trusted certificate or use a properly configured reverse proxy before treating the connection as secure.
The first screen asks for an administrator password. Portainer also records an initial temporary password in its container log, which can be viewed with sudo docker logs portainer. Change that password during setup and avoid publishing the log. If the setup window has expired, reset the credential with sudo docker exec portainer portainerctl reset-password, then use the new temporary password to complete the setup.
Restrict access with UFW and any cloud firewall. A fixed administration address can be allowed with:
sudo ufw allow from 203.0.113.24 to any port 9443 proto tcp
Replace the example address with your own. An SSH tunnel is often better for an Australian NBN or 5G connection without a public IP:
ssh -L 9443:localhost:9443 ubuntu@203.0.113.24
Then visit https://localhost:9443. For cloud VPS instances in Sydney or Melbourne, open port 9443 in the provider’s security group as well as UFW. A VPN such as Tailscale or WireGuard provides a practical alternative when the home connection changes address frequently.
Manage images, stacks, containers, and volumes
Portainer’s local environment groups containers, images, volumes, networks and stacks into one interface. Container views provide logs, statistics, process details, console access and lifecycle controls. These actions use the permissions already granted to the Docker socket, so administrative access to Portainer should be limited to people who would be trusted with direct access to sudo docker.
Stacks are the easiest way to manage a related set of containers. Select Stacks, add a stack and paste a Compose definition into the editor:
services:
web:
image: nginx:stable-alpine
restart: unless-stopped
ports:
- "8080:80"
mem_limit: 256m
cpus: "0.50"
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
cache:
image: redis:7-alpine
restart: unless-stopped
volumes:
- cache-data:/data
volumes:
cache-data:
The port must be free, and the image tags must exist for the server’s processor architecture. Memory and CPU limits prevent one workload from exhausting a small VPS. Log rotation is particularly valuable because JSON log files can otherwise consume a surprising amount of disk space.
Named volumes preserve data when a container is replaced, while deleting a stack may offer to remove its volumes as well. Bind mounts are useful for files that must remain visible on the host, such as configuration under /srv/app. Use Portainer’s stack editor for routine environment changes, but keep a copy of the Compose file in version control. Avoid placing credentials directly in that file, and use image tags specific enough to make deployments repeatable.
Images and stacks require separate attention when updating. Portainer can pull or redeploy an image, but a container does not receive new application code merely because its original image tag was set to latest. Review release notes, pull the intended image and recreate the container or stack while confirming that its volumes, environment variables, ports and restart policy remain intact.
Protect access and maintain the deployment
The Docker socket grants powerful control over the host. Keep port 9443 off the open internet unless a hardened TLS reverse proxy, reliable authentication and network-level restrictions protect it. Use unique administrator credentials, remove unused accounts and audit who can reach the server. For remote work, a private VPN is simpler to operate than repeatedly opening ports on a home router.
Firewall rules are only one layer. Australian cloud environments commonly use regional security groups alongside UFW, so both must permit the chosen path. If the server is in AWS ap-southeast-2, Azure australiaeast or Google Cloud australia-southeast1, apply the rule in that provider’s console as well. Restrict the source network rather than accepting connections from every address, and remember that a public cloud address may still be shared or protected by provider-level controls.
Back up Portainer’s portainer_data volume and the volumes used by applications. A brief stop gives Portainer’s database a more consistent copy:
sudo mkdir -p "$HOME/docker-backups"
sudo docker stop portainer && \
sudo docker run --rm \
-v portainer_data:/source:ro \
-v "$HOME/docker-backups":/backup \
alpine tar czf /backup/portainer-data-$(date +%F).tgz -C /source . && \
sudo docker start portainer
Repeat the process for application volumes, and use database-specific dumps when possible. Test a restore rather than assuming an archive is usable. For Australian organisations, an encrypted copy in a bucket in a Sydney or Melbourne region may suit local latency and data-residency requirements, subject to the provider’s terms.
Updates need a controlled maintenance window. Check Ubuntu packages with sudo apt update and apt list --upgradable, then run sudo apt upgrade after taking backups. Upgrading Docker can restart the daemon and therefore affect running containers. Portainer itself is not automatically replaced when its image changes: pull the selected release, recreate the container and retain the same data volume. Pin the tested version so later maintenance produces the same result.
Diagnose faults and keep storage under control
When Portainer will not load, work through the layers in order. Check systemctl is-active docker, inspect the container with sudo docker ps -a --filter name=portainer, and read recent output with sudo docker logs --tail 100 portainer. The command sudo ss -ltnp | grep 9443 shows whether the port is listening. A timeout can then point to UFW, a cloud security group, an incorrect IP address or a required SSH tunnel.
Application containers fail for different reasons. Read their logs, inspect the exit code and check whether an environment variable or mounted path is missing. Commands such as sudo docker logs --tail 200 <container-name> and sudo docker exec -it <container-name> sh provide useful evidence. Port conflicts appear in the ss output, while permission errors often involve the ownership of a bind-mounted directory. Portainer’s statistics view can also reveal a process consuming unexpected memory or CPU.
Disk pressure requires careful cleanup. Use df -h for filesystem usage and sudo docker system df to see Docker’s reported consumption. sudo docker system prune removes unused containers, networks, dangling images and build cache, but it does not remove volumes unless the additional volumes option is supplied. Use targeted image or builder pruning where possible and treat volume deletion as a separate decision. Australian VPS plans often advertise monthly transfer allowances in gigabytes, and pulling several large images can use a noticeable share of that allowance.
The durable arrangement is simple: Docker remains the engine, Portainer provides the control panel, application data lives outside disposable containers, and access is restricted to trusted networks. The combination to remember is a pinned image, a tested backup, restricted access and a repeatable update path.