Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk9 min

How to Run Memcached in a Docker Container

Start Memcached with Docker, expose port 11211 safely, connect application containers by service name, tune memory and connections, and troubleshoot common failures.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The shortest working command is docker run --name my-memcache -d memcached. It starts the Memcached server in the background, but it does not publish the cache to your host. Add -p 127.0.0.1:11211:11211 when a process running on the host must connect. For an application running in another container, put both containers on the same user-defined Docker network and use my-memcache:11211 (or the Compose service name) as the endpoint.

Memcached is an in-memory cache, not a database. Entries can disappear when the container stops, memory is exhausted, or the cache evicts older items. Treat it as an acceleration layer in front of durable storage.

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.

Start Memcached with the official image

Docker’s maintained Memcached image uses the image name memcached. The default variant is Debian-based and is a practical starting point when compatibility and familiar troubleshooting tools matter.

  1. Confirm Docker Engine or Docker Desktop is installed and that your user can run docker commands.
  2. Start a detached container:
docker run --name my-memcache -d memcached

The --name option gives the container a stable name, -d leaves it running in the background, and the final argument selects the image. If the image is not already present locally, Docker downloads it first.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Check that the container is running:

docker ps --filter name=my-memcache

View startup output if it is not listed:

docker logs my-memcache

A container that exits immediately usually indicates an invalid command or an option that Memcached rejected. The log output identifies the failure; correct the command and recreate the container rather than repeatedly restarting a bad configuration.

Choose how the cache should be reachable

Docker networking determines whether you need port publishing. Publishing is for access through the Docker host; containers on the same user-defined network can communicate directly without it.

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.
Use case Run-time network setting Memcached address used by the client Exposure
Application and cache are both containers Attach both to one user-defined network my-memcache:11211 or the Compose service name No host port required
Application runs on the Docker host Publish 127.0.0.1:11211:11211 127.0.0.1:11211 Loopback only
A controlled external client must connect Publish a host address and port deliberately The selected host address and port Reachable wherever that host address is routable
No client needs direct access yet Do not publish a port Only clients sharing a Docker network can connect Not exposed through the host

When you write -p 11211:11211 without a host IP, Docker publishes the port on all host interfaces by default. That can make a development cache reachable from other machines. Use an explicit host address whenever access should be limited.

Publish port 11211 for a host process

Memcached’s conventional TCP port is 11211. To let software running directly on the host connect through loopback, remove any earlier container with the same name and run:

docker run --name my-memcache -d -p 127.0.0.1:11211:11211 memcached

The left side of the mapping is the host address and port; the right side is the port inside the container. Confirm the mapping Docker applied:

docker port my-memcache

Your host-side Memcached client should now be configured for 127.0.0.1 and port 11211. If another process already owns that host port, Docker reports a port-allocation error. Either stop the conflicting process or select another host port, such as 127.0.0.1:11212:11211; in that case the host client uses 11212, while Memcached still listens on 11211 inside the container.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Connect another container over a private Docker network

For container-to-container traffic, create a user-defined bridge network and attach both services to it. Docker’s embedded DNS resolves a container or service name on that network.

  1. Create the network once:
docker network create app-net
  1. Start Memcached without publishing a host port:
docker run --name my-memcache --network app-net -d memcached
  1. Start your application on the same network. The application’s cache host is my-memcache and its cache port is 11211:
docker run --name my-app --network app-net -d your-application-image

Replace the application image with the image used by your service. Do not configure the application to use localhost: inside a container, localhost refers to that application container itself, not the Memcached container.

Container names are convenient for a single Docker host. In a Compose project, use the service name, which remains the stable DNS name even if Compose recreates the container.

Use Docker Compose for repeatable local environments

A Compose file keeps the image, network, and Memcached flags in one declarative configuration. This example sets a 1,024-connection limit, a 64 MB cache limit, and four worker threads:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
services:
  memcached:
    image: memcached
    command:
      - --conn-limit=1024
      - --memory-limit=64
      - --threads=4

Start the service from the directory containing the file:

docker compose up -d memcached

Other services declared in the same Compose project automatically share the project network. Configure them to use host memcached and port 11211; no ports section is necessary unless a host or external client also needs access.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

If you do need host access, add a scoped mapping:

services:
  memcached:
    image: memcached
    ports:
      - "127.0.0.1:11211:11211"
    command:
      - --conn-limit=1024
      - --memory-limit=64
      - --threads=4

Run docker compose logs memcached to inspect startup messages and docker compose down to stop and remove the project’s containers and network. Removing the container removes its in-memory contents.

Inspect available Memcached options before tuning

Memcached options vary by release, so inspect the flags supported by the image you selected rather than copying an option blindly:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
docker run --rm memcached -h

The --rm flag deletes this short-lived help container after the command exits. The official image documentation demonstrates these useful settings:

Memory limit

Set the cache size in megabytes with --memory-limit. For example, this gives the server a 64 MB cache:

docker run --name my-memcache -d memcached memcached --memory-limit=64

This is a cache capacity, not a reservation that guarantees the Docker host has that amount of free RAM. Leave room for the Memcached process, the container runtime, and your application. When the cache fills, Memcached evicts older entries using least-recently-used behavior; an eviction is expected cache operation, not durable data loss recovery.

Connection limit

--conn-limit=1024 raises the maximum simultaneous connection count to 1,024 in the documented Compose example. Choose a limit that matches your application’s connection pooling and available file descriptors; a higher limit alone does not improve performance.

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.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Worker threads

--threads=4 starts four Memcached worker threads in the documented example. Thread count should reflect the CPU resources assigned to the container and the concurrency of your clients. Measure application behavior before increasing it.

Listening interface and port

Since Memcached 1.5.6, the server defaults to listening only on TCP. The -l option binds it to selected interfaces. Binding deliberately is useful when a container has more than one reachable interface or when you want to restrict which addresses accept connections.

If you change the Memcached listening port with its port option, map the same container port in Docker. For example, a server configured to listen on 11212 needs a mapping whose right-hand side is also 11212. A mismatch between the server’s listening port and Docker’s container port produces connection failures even when the container is running.

Select an image tag deliberately

The unqualified memcached image is the default Debian-based variant. The official image also publishes versioned tags and Alpine-based variants. The right choice depends on reproducibility, compatibility, and image size.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Image choice Advantages Trade-offs When it fits
Unqualified memcached Simple quick start; Debian-based compatibility It follows the image’s changing default tag Local development and initial testing
Exact version tag Reproducible pulls and controlled upgrades You must plan updates and security maintenance CI, staging, and production deployments
Alpine variant Much smaller image footprint Uses musl libc; commonly omits tools such as Bash and Git Deployments where size matters and your tooling is compatible

For a long-lived deployment, pin an exact version tag rather than relying indefinitely on latest or another moving tag. Test the selected tag with your client libraries and operational tooling before promoting it. Choose Alpine only after confirming that musl libc and the reduced troubleshooting toolset are acceptable.

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

Verify connectivity without guessing

Use Docker’s own inspection commands first:

  • docker ps --filter name=my-memcache confirms whether the container is running.
  • docker logs my-memcache shows startup errors and command-line parsing failures.
  • docker port my-memcache displays the host-to-container port mapping.

Memcached speaks a text protocol over TCP. A Memcached-aware client from your application, or a deliberately installed diagnostic utility, can open a connection and issue stats. The response should contain server statistics; an inability to connect points to the address, port, network, or listening-interface configuration rather than to a cache key problem.

If a host client gets “connection refused”

  • Check whether you started the container with -p. Without publishing, the host cannot reach the container through 127.0.0.1:11211.
  • Run docker port my-memcache and use the displayed host port.
  • Inspect logs for a failed startup or an invalid Memcached option.
  • Confirm that another local service is not using the selected host port.

If one container cannot reach another

  • Ensure both containers are attached to the same user-defined network.
  • Use the Memcached container or Compose service name, not localhost and not the host’s published address.
  • Use port 11211 unless you intentionally changed Memcached’s listening port.
  • Check that the server is listening on an interface reachable from that network; an overly restrictive -l setting can prevent access.

If the container keeps restarting or exits

Read docker logs before changing resource limits. A malformed flag, unsupported option, or an occupied host port is usually visible there. Recreate the container after correcting the command; changing a stopped container’s original command is not supported.

Operate the cache safely

Protect the network boundary

Memcached is designed to serve trusted application clients, not to be an open Internet service. Avoid an unrestricted -p 11211:11211 mapping on a host that has untrusted or public interfaces. Prefer no host publishing for container-only traffic, or bind to loopback for local development. If remote access is unavoidable, publish only the required host address and enforce network-level access controls outside the container.

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

Plan for volatility

Memcached stores objects in RAM. Restarting, replacing, or removing the container clears the cache; so can eviction when the configured memory limit is reached. Keep the authoritative copy in a database or other durable system and make cache misses safe. Do not use Memcached as the only location for sessions, queues, user records, or any data that must survive a restart.

Size memory and connections together

The documented 64 MB memory limit, 1,024 connection limit, and four threads are examples, not universal production values. Select memory based on the working set you intend to cache and the RAM available to the Docker host. Select connections from observed client concurrency, and leave operating-system headroom. Monitor evictions, connection errors, latency, and container memory pressure so that a full cache is distinguishable from an application outage.

Use a controlled upgrade process

Pin the image version, test a newer tag in a separate environment, then replace the running container during a planned deployment. Because the cache is disposable, the replacement will begin cold; expect a temporary increase in database or API reads while entries are repopulated. Keep the same network name, service name, memory settings, and connection settings so application configuration does not change during the replacement.

Stop, restart, and remove the container

These lifecycle commands manage the example container:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
docker stop my-memcache
docker start my-memcache
docker restart my-memcache
docker rm -f my-memcache

docker stop preserves the stopped container for a later docker start. docker restart stops and starts it in one operation. docker rm -f forcibly removes it and deletes all cached objects. If you need the cache to return automatically after a Docker daemon or host restart, add an appropriate Docker restart policy when creating the container and verify that policy in your deployment standards.

Practical deployment checklist

  • Use the official memcached image and pin a version for reproducible environments.
  • Run docker run --rm memcached -h against the chosen image before adding tuning flags.
  • Keep container-only traffic on a user-defined network and use the service or container name as the hostname.
  • Publish port 11211 only when a host or external client needs it; specify a host IP instead of relying on Docker’s all-interface default.
  • Set memory, connection, and thread limits according to measured workload and available host resources.
  • Verify startup with docker ps, docker logs, and docker port, then test with your application’s Memcached client.
  • Keep authoritative data outside Memcached and design for misses, evictions, and cold starts.
  • Document the selected image tag, network name, listening port, and command flags so another operator can recreate the service.

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 *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.