Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Change Docker Container Run Options After Creation

Docker run flags are mostly fixed at creation. This guide explains docker update, safe container replacement, Compose recreation, volume preservation, and networking effects.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Short answer: Docker does not provide a general editor for every option passed to docker run. Use docker update for the documented resource and restart-policy settings that are mutable. To change ports, environment variables, mounts, commands, entrypoints, capabilities, devices, DNS, networks, labels, or the image, create a replacement container with the desired configuration. With Compose, edit the service definition and run docker compose up; Compose stops and recreates affected containers while preserving mounted volumes.

Why most docker run options cannot be edited

A Docker container is created from an image plus a configuration record. That record includes the process command, environment, mounts, published ports, namespace and network attachments, security settings, and other choices supplied when the container was created. Starting the container again does not rebuild that record. It only starts the same container with the same configuration.

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.

This distinction explains a common surprise: docker start app cannot apply a newly typed -p, -e, -v, or command flag. Those options describe how a container is created, not how an existing stopped container is started. Docker exposes a narrow set of mutable controls through docker update; everything else is normally changed by replacing the container.

Think of a container’s name as an identifier for one container instance, not a permanent machine. A replacement can use the same name after the old instance is stopped and removed, while important state remains in a named or bind-mounted volume.

#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.

Use docker update for supported live changes

The docker update command (also available as docker container update) changes resource controls and the restart policy on an existing container. It does not turn every docker run flag into an editable setting.

Resource controls that can be updated

  • CPU shares and CPU limits, including the number of CPUs available.
  • Memory and swap limits.
  • PID limits.
  • Block-I/O weight.
  • CPU and memory pinning.
  • The container’s restart policy.

For example, this changes CPU and memory limits and tells Docker to restart the container unless it has been explicitly stopped:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
docker update --cpus 2 --memory 1g --restart=unless-stopped my-container

Restart-policy changes take effect immediately. You do not have to stop and recreate the container merely to change --restart.

Important limitations

  • A container created with --rm cannot have its restart policy updated. Automatic removal and an automatic restart policy are mutually exclusive.
  • docker update is not supported for Windows containers.
  • Exact flags and API availability depend on the Docker Engine version. Check the client and server versions with docker version, then consult the local command help with docker update --help before a production change.

After changing a limit, inspect the container to verify the effective configuration:

docker inspect my-container

Resource changes affect the existing container’s runtime constraints. They do not alter its image, command, environment, mounts, published ports, or network topology.

Options that require a replacement container

Recreate the container when you need to change any of the following:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Published or exposed ports, such as adding -p 8080:80.
  • Environment variables supplied with -e or --env-file.
  • Bind mounts and named volumes, including their destination paths.
  • The image reference or image tag.
  • The entrypoint or command.
  • The container user, Linux capabilities, devices, or other security settings.
  • DNS settings, network attachments, aliases, or other network topology.
  • Container labels and other creation-time metadata.

There is no safe trick that appends a port or environment variable to an already-created container. Editing files inside the container, restarting it, or renaming it does not change Docker’s stored configuration. Build a new container with the complete desired configuration instead.

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

A safe replacement workflow with the Docker CLI

The following pattern keeps the old instance available for rollback while you validate the replacement. It assumes that persistent application data is outside the container’s writable layer.

  1. Record the current configuration. Capture the image, mounts, environment, networks, and other settings before changing anything:
    docker inspect app > app-before-change.json

    Review the output and identify every volume or bind mount that must be reused. If the application stores state only in the container’s writable layer, replacing it can discard that state.

  2. Stop the running container.
    docker stop app

    Stopping closes the service’s active connections. Schedule the operation for a maintenance window if clients cannot tolerate that interruption.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  3. Free the intended name without deleting the old instance.
    docker rename app app-old

    Renaming lets you create a new container called app while retaining app-old for inspection or rollback.

  4. Create the replacement with the complete configuration.
    docker run -d --name app 
      -p 8080:80 
      -e APP_ENV=production 
      -v app-data:/var/lib/app 
      image:tag

    Include all required options, not just the one you intended to change. The example publishes host port 8080 to container port 80, sets an environment variable, and reuses the named volume app-data.

  5. Validate before deleting anything. Check that the new container is running and that the application responds:
    docker ps
    docker logs --tail=100 app
    docker inspect app

    Confirm the published port, mounted volume, environment, command, health status, and network attachments. Exercise a real application request if one is available.

  6. Remove the old container only after validation.
    docker rm app-old

    Do not remove the old instance until you have confirmed that the replacement has the expected behavior and data.

    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)

Rollback if the replacement fails

If the new container will not start or fails validation, stop and remove the replacement, then restore the previous name:

docker stop app
docker rm app
docker rename app-old app
docker start app

This rollback works because the old container was preserved. If you changed or migrated the shared application data, follow the application’s own rollback procedure before restarting the old instance.

How to avoid data loss

  • Use a named volume, such as app-data, for state that must survive container replacement.
  • Use a bind mount when the files need to remain directly accessible on the host.
  • Do not assume that a container’s writable layer is durable once the container is removed.
  • Make sure the replacement uses the same volume name and container mount path expected by the application.
  • Back up important data before changing an image, schema, or application version; a volume preserves files but does not guarantee that a newer application can read them.

Changing a Compose-managed service

For a service defined in compose.yaml, the Compose file should remain the source of truth. Edit the service’s ports, environment, volumes, command, entrypoint, image, restart, or other setting, then reconcile the service:

docker compose up -d SERVICE

If an existing service container was created with a different configuration or image, Compose stops and recreates it. Mounted volumes are preserved during that replacement. The service name remains stable for Compose’s internal discovery, but the container itself is a new instance.

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.

Force or prevent recreation deliberately

  • Use docker compose up -d --force-recreate SERVICE when you need a replacement even though Compose does not detect a configuration or image difference.
  • Use docker compose up -d --no-recreate SERVICE only when you intentionally want to leave existing containers untouched. It will not apply new run options to that container.

Limit the command to the affected service when possible. This reduces unnecessary disruption to unrelated services in the project.

Why docker compose restart did not apply your edit

docker compose restart stops and starts the existing container. It is useful for restarting a process, but it is not a configuration deployment command. Changes made in the Compose file, including environment-variable changes, are not reflected by restart. Run docker compose up -d SERVICE instead so Compose can reconcile the stored container with the file.

Rebuilding an image and redeploying one service

When the Dockerfile or application source requires a new image, build the service and then recreate only that service:

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
docker compose build web
docker compose up --no-deps -d web

--no-deps prevents Compose from restarting dependency services as part of this targeted deployment. Use it when those dependencies do not need to change.

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

What replacement changes for clients and networks

Compose preserves mounted volumes, not the identity of the old container. Existing connections to the old container close when it is stopped. The recreated service receives a new container IP address, even though its Compose service name remains the same.

Applications should therefore connect to the service name and resolve it again after a deployment. Do not pin a client to the previous container IP. A client with connection pooling should discard failed connections and establish new ones after the service is recreated.

Published host ports can remain the same if the old container has been stopped before the replacement starts. If another process or container is already using that host port, creation fails; resolve the conflict before deleting the known-good instance.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use docker compose run for temporary experiments

When you want to test a different command, environment variable, port, volume, user, or entrypoint without changing the long-running service, use a one-off container:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
docker compose run SERVICE COMMAND

This is useful for migrations, diagnostics, and short-lived experiments. It does not publish the service’s configured ports by default. Add --service-ports to publish the ports declared for the service, or pass an explicit --publish option for a temporary mapping.

A one-off container does not update the service definition. If the experiment becomes the desired production configuration, edit compose.yaml and run docker compose up -d SERVICE so the managed service is recreated from the declared settings.

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.

Choosing between an in-place update and recreation

Situation Correct operation Container identity and data Configuration source
CPU, memory, swap, PID, block-I/O, CPU/memory pinning, or restart policy docker update The existing container remains; mounted data is unchanged. CLI command and the engine’s stored settings.
Port, environment, mount, command, entrypoint, user, capability, device, DNS, network, label, or image change Stop and recreate the container with the full desired configuration. The container identity changes; named and bind-mounted data can be reused. Active connections close. Your replacement command or deployment definition.
Compose service configuration or image changed Edit compose.yaml, then run docker compose up -d SERVICE. Compose recreates the service and preserves mounted volumes; the new instance gets a new IP. compose.yaml.
Temporary command or environment test docker compose run, with --service-ports or --publish when needed. A one-off container is created; the managed service is not changed. The one-off command-line options.

Common requests and the correct procedure

“Can I add a port to the existing container?”

No. Stop the old container, create a replacement with the new -p HOST:CONTAINER mapping, and reuse its named or bind-mounted volumes. For Compose, add the mapping under the service’s ports list and run docker compose up -d SERVICE.

“Can I add or change an environment variable?”

Not on the existing container. Add the variable to the replacement’s -e option or to the Compose service’s environment section, then recreate. Verify the resulting environment with docker inspect; be careful not to expose secrets in shell history or diagnostic output.

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

“Can I change the command or entrypoint?”

Those define the process Docker starts and require a new container. A one-off docker compose run is appropriate for a temporary command; use the service definition and docker compose up for a lasting change.

“Can I change only the image tag?”

Replace the container with the new image reference. In Compose, edit image, pull or build as appropriate, and run docker compose up -d SERVICE. Keep the volume mapping consistent and check application compatibility before removing the old instance.

“Why did my update command fail?”

  • Check that the option is one of the resource or restart-policy settings supported by docker update.
  • Check whether the container is a Windows container; Docker does not support docker update for Windows containers.
  • Check whether the container was created with --rm when attempting to alter its restart policy.
  • Confirm the Docker Engine version and the local CLI help because supported flags can vary by release.

“Why did Compose recreate the service but my data disappear?”

Compose preserves mounted volumes, not files stored only in the old container’s writable layer. Inspect the old container’s mounts before replacement, then ensure the new service references the same named volume or host directory at the expected path. If the data was never mounted, stop further changes and investigate the old container before removing it.

Pre-deployment checklist

  • Classify the requested change: supported resource update, permanent recreation, Compose deployment, or one-off experiment.
  • Record the current container configuration and identify every persistent-data mount.
  • Confirm the replacement image, command, environment, ports, networks, users, and security options as a complete set.
  • Plan for the connection interruption caused by stopping the old container.
  • Keep the old container under a temporary name until health, logs, ports, and application behavior are validated.
  • Use service-name discovery rather than a previously observed container IP.
  • Remove the old container only after validation and after confirming that the rollback path is no longer needed.

The practical rule is simple: adjust resources in place when Docker documents the setting as mutable; otherwise declare the desired configuration and create a new container. Treat volumes as the durable boundary, Compose as the declarative source of truth, and container IP addresses as disposable.

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

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 *

Free tools Windows power users keep installed

One-click scans. No signup required.

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
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver 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.