October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Create a Docker Container on a Linux VPS

A practical Linux VPS guide to installing Docker Engine, choosing between docker create and docker run, publishing ports and checking that your container works.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Docker Engine, obtain an image, then create and start a container with either two commands (docker create followed by docker start) or one docker run command. The example below publishes an Nginx web server on VPS port 8080 and shows how to verify, troubleshoot and safely manage it.

What you need before creating the container

A Docker container cannot be created until Docker Engine is installed on the VPS. You also need an SSH connection, an account that can use sudo, an image name, and a host port that is available for the service you intend to run.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Linux VPS: The commands below use Ubuntu-style package management and the standard Docker CLI.
  • Administrative access: Docker installation and port/firewall changes normally require root privileges or sudo.
  • A container image: The examples use nginx, which supplies a web server listening on container port 80.
  • A network plan: Decide which VPS port should receive traffic and which port the application listens on inside the container.

Check the VPS provider’s firewall as well as any firewall running on the operating system. Publishing a port without restricting access can make the service reachable from every network interface on the VPS.

Install Docker Engine on an Ubuntu VPS

Use Docker’s official APT repository rather than an unrelated package source. Package names and supported Ubuntu releases can change, so consult Docker’s current Ubuntu installation instructions for the release running on your VPS before executing the repository setup.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Remove conflicting packages

Older or unofficial packages can conflict with Docker Engine. Remove packages such as docker.io and docker-compose if they are installed. Other packages that may need removal include older Docker documentation packages, Podman compatibility packages, containerd and runc installed independently of Docker. Removing a package does not automatically remove your image and container data, but confirm what APT proposes before accepting the transaction.

sudo apt remove docker.io docker-compose docker-doc podman-docker containerd runc

Configure Docker’s repository and install the engine

Update APT, install the certificate and download utilities required by the repository setup, add Docker’s signing key and repository for your Ubuntu release, then install the Docker Engine packages offered by that repository. The exact repository stanza is release-dependent; use Docker’s official, current command for your release instead of copying a command intended for a different Ubuntu version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt update
sudo apt install ca-certificates curl
# Add Docker's official signing key and APT repository using
# the commands for your Ubuntu release.
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

After installation, run a harmless Docker command with sudo to confirm that the client can reach the engine:

sudo docker version

If the command reports that Docker is not available, finish the repository setup, check that the Docker service is running according to the installation guide, and retry. Avoid installing a second Docker implementation on top of a partially configured one.

Understand images, containers and ports

Image versus container

An image is the packaged filesystem and metadata used as the starting point. A container is a runnable instance created from that image. Creating a container adds a writable layer over the image and records its configuration, including the name, port mappings and command. The image itself is not changed when the container writes data to that writable layer.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Container port versus VPS port

The application listens on a port inside the container. Docker can publish that port on the VPS with -p HOST_PORT:CONTAINER_PORT. For example, -p 8080:80 sends connections arriving at VPS port 8080 to port 80 in the container. If you omit a host IP, Docker publishes the host port on all interfaces by default, represented by 0.0.0.0. Treat that as a public exposure unless your VPS firewall limits it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why EXPOSE is not the same as publishing

An image’s Dockerfile may contain an EXPOSE declaration. That documents an intended container port; it does not, by itself, make the service reachable on the VPS. The -P or --publish-all option publishes ports exposed by the image (or supplied with --expose) using automatically selected host ports. A predictable public port normally requires an explicit -p mapping.

Create a container without starting it

Use docker create when you want to define the container first and start it later. The command returns a container identifier and leaves the container stopped.

sudo docker create --name web -p 8080:80 nginx

This records a container named web, based on the nginx image, with VPS port 8080 mapped to container port 80. The image may be downloaded if it is not already present locally. No Nginx process is serving traffic yet because the container has not started.

Start the created container

sudo docker start web

docker start starts an existing stopped container using the configuration captured at creation time. You refer to it by the custom name rather than an automatically generated name.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Create and start in one command with docker run

For the common case where no separate preparation step is needed, docker run combines creation and startup:

sudo docker run -d --name web -p 8080:80 nginx

The first run creates the container and starts it. The -d option, also written --detach, leaves the process running in the background and returns control of the SSH session to you. The custom name makes later commands predictable.

Docker’s getting-started example follows the same pattern with a different image:

docker run --detach --name welcome --publish 8080:80 docker/welcome-to-docker

Use either the short or long spelling of an option; they express the same setting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run options that matter on a VPS

Option Effect Example
-d / --detach Runs the container in the background. -d
--name Assigns a chosen name instead of a random name. --name web
-p / --publish Maps a host port to a container port. -p 8080:80
-P / --publish-all Publishes ports declared with the image’s EXPOSE instruction or supplied with --expose, using Docker-selected host ports. -P

Detached mode does not make a container permanent. A detached container exits when its root process exits. If you also specify --rm, Docker removes the container automatically after it exits, which is useful for disposable jobs but unsuitable when you need to inspect the stopped container later.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Verify that the container is running

List running containers

sudo docker ps

The output should include the web container, its running status and the published port mapping. If it is absent, it may have exited immediately or may never have been started.

List running and stopped containers

sudo docker ps -a

The -a option is essential during troubleshooting because it includes containers that have stopped. Look for the container name, status and exit information.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Test the published service

From a browser or an HTTP client, request the VPS address on port 8080. The request reaches Nginx only when the container is running, the mapping is correct and the VPS/provider firewall permits that port. If the service should be private, bind it to a specific host address or restrict the port with firewall rules rather than relying on the container’s existence as a security boundary.

Manage the container after creation

Stop and start it

sudo docker stop web
sudo docker start web

Stopping ends the running process; starting reuses the same container and its configured port mapping. You do not need to run docker create again for a container that already exists.

Read logs

sudo docker logs web

Logs often reveal configuration errors or an application that terminated during startup. Add -f to follow new log output while diagnosing a live process.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Remove a container you no longer need

sudo docker stop web
sudo docker rm web

Removal deletes the container’s writable layer and configuration, but it does not delete the image. Re-create it later with the original docker run or docker create command. Do not remove a container that holds data you have not copied to a volume or another storage system.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

docker create versus docker run

Question docker create plus docker start docker run
Does the initial command start the container? No. docker create leaves it stopped; docker start starts it later. Yes. It creates and starts the container in one operation.
How many commands are required for a running container? Two: create, then start. One.
When is it useful? When you want to inspect or stage configuration before startup. When the image, name and port mapping are already decided.
How do you reference it afterward? Use the name assigned with --name, such as web. Use the name assigned with --name, such as web.

Both approaches produce a normal Docker container. The difference is the point at which Docker starts its root process.

Troubleshoot the common failure points

“Docker: command not found”

Docker Engine is not installed for the current system, or the installation did not complete. Confirm that you used the official repository instructions for the VPS’s Ubuntu release, then install the engine packages and rerun sudo docker version.

Permission denied when omitting sudo

Use sudo consistently while setting up the server. Whether you later configure non-root Docker access depends on your security policy; membership in a Docker-management group is effectively powerful administrative access, so do not grant it casually.

“Port is already allocated”

Another process or container is already using the selected host port. Run sudo docker ps and sudo docker ps -a to find existing containers, choose a different host port such as 8081, or stop the conflicting service. The container-side port can remain 80 if the application still listens there.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The container appears in ps -a but not ps

It is stopped. Inspect sudo docker logs web, check the image’s startup configuration and try sudo docker start web after correcting the underlying issue. A detached container exits when its root process exits; Docker will not keep an already-terminated process alive automatically.

The port is published but the site is unreachable

  • Confirm the container is running with sudo docker ps.
  • Confirm the mapping shows 8080->80 (or the ports you selected).
  • Check the VPS operating-system firewall and the provider’s network firewall.
  • Verify that the client is using the VPS address and host port, not the container port directly.
  • Remember that an explicit -p without a host IP binds all host interfaces by default; firewall rules must enforce any intended restriction.

Security and operational checks for a public VPS

  • Expose only required ports. Prefer explicit -p HOST:CONTAINER mappings over publishing every exposed port with -P.
  • Review the bind address. A mapping without a host IP listens on all interfaces. If the service is for local administration, bind it to an appropriate private or loopback address and enforce the same policy in the firewall.
  • Use a deliberate name. Names such as web make stop, start, log and inspection commands less error-prone than random names.
  • Keep state outside the disposable layer. A container can be removed and re-created; important application data should live in a planned persistent storage arrangement rather than only in the container’s writable layer.
  • Record the exact command. The original image, name and port mapping are the recipe for rebuilding the service after removal or a VPS migration.

A repeatable creation checklist

  1. Connect to the Linux VPS over SSH and confirm that your account can use sudo.
  2. Identify the Ubuntu release and follow Docker’s current official APT-repository instructions for that release.
  3. Remove conflicting packages such as docker.io or docker-compose after reviewing APT’s proposed changes.
  4. Install Docker Engine and confirm it responds to sudo docker version.
  5. Choose an image and decide the container’s internal listening port.
  6. Choose an unused VPS port and map it with -p HOST_PORT:CONTAINER_PORT.
  7. Use sudo docker create --name NAME -p HOST:CONTAINER IMAGE followed by sudo docker start NAME, or use sudo docker run -d --name NAME -p HOST:CONTAINER IMAGE.
  8. Run sudo docker ps to verify a running container and sudo docker ps -a when stopped containers must be included.
  9. Test the service through the VPS host port and check both firewall layers if the connection fails.
  10. Use docker logs, docker stop, docker start and docker rm to operate the named container throughout its lifecycle.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.