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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

The quickest way to start Memcached with Docker is:

docker run --name my-memcache -d memcached

That starts the official image in the background. Publish port 11211 only when a process outside Docker must connect. For a host application that should reach a local-only cache, use:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
docker run --name my-memcache -d -p 127.0.0.1:11211:11211 memcached

For an application running in another container, put both containers on the same user-defined network and connect to the hostname my-memcache (or the Compose service name) on port 11211. Memcached stores data in volatile RAM, so it can speed up database and API access but cannot replace durable storage.

Choose the right Docker command

Your connection requirement determines the command:

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
Use case Command Why
Only other containers on the same Docker network need Memcached docker run --name my-memcache -d memcached No host-port publishing is necessary.
A process on the Docker host needs a local cache docker run --name my-memcache -d -p 127.0.0.1:11211:11211 memcached Publishes the standard port to loopback only.
An external machine needs access docker run --name my-memcache -d -p 11211:11211 memcached Publishes on all host interfaces by default; use only with deliberate network controls.

Docker’s -p syntax is host-port:container-port. If you omit the host IP, Docker binds the published port on all interfaces, not just localhost. That distinction is important because a cache intended for one machine can otherwise become reachable from other networks.

What Memcached does inside a container

Memcached is a general-purpose distributed memory object cache. Applications place frequently requested values in it, then retrieve those values from RAM instead of repeatedly querying a database, filesystem, or remote API. A cache hit can avoid that slower operation; a cache miss sends the application back to its original data source.

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

Memcached is not a database and does not provide durable storage. Entries disappear when the process is stopped, the container is removed, or the cache needs the memory for newer entries. When the cache reaches its configured limit, older entries are purged using least-recently-used behavior. Design your application so every cached value can be recreated from authoritative storage.

The container provides process isolation and a repeatable way to start the server. It does not make the data persistent. A Docker volume is therefore not a substitute for a database backup or durable Memcached state.

Prerequisites

  • Docker Engine or Docker Desktop must be installed and running.
  • The host must have enough memory for the Memcached limit you intend to configure, plus Docker and your application workload.
  • Choose in advance whether clients are on the host, in other containers, or on another machine. That choice determines whether you publish port 11211.
  • If you use a Compose file, create it in the directory where you will manage the application stack.

Start the official image

1. Run the default instance

  1. Open a terminal on the Docker host.
  2. Start Memcached in detached mode:
    docker run --name my-memcache -d memcached
  3. Confirm that Docker reports a container ID and that the container appears in the running-container list:
    docker ps --filter name=my-memcache

The unqualified memcached image is the default Debian-based variant. It is a sensible starting point when compatibility and familiar troubleshooting tools matter more than the smallest possible image.

2. Publish the port for a host process

Use an explicit loopback binding when a program on the same host should connect through localhost:11211:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
docker run --name my-memcache -d -p 127.0.0.1:11211:11211 memcached

The first 11211 is the host port; the second is the port inside the container. A host application can now use 127.0.0.1:11211.

3. Publish for a deliberately external client

If a client outside the Docker host must connect, the basic mapping is:

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
docker run --name my-memcache -d -p 11211:11211 memcached

This exposes the port on every host interface by default. Restrict access with the host firewall, private network rules, or a specific host address rather than assuming the cache is private because it runs in a container. Do not publish the port at all when only same-network containers need it.

Verify that the container is running

Use Docker’s built-in inspection commands before debugging an application:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
docker ps --filter name=my-memcache
docker logs my-memcache
docker port my-memcache
  • docker ps shows whether the container is up and how long it has been running.
  • docker logs displays the Memcached process output. An empty log is not automatically an error; the daemon normally produces little output during a healthy idle run.
  • docker port reports the host-to-container mapping. It is the quickest way to confirm whether port 11211 was published and which host address owns it.

To see the command-line options supported by the image, run:

docker run --rm memcached -h

The --rm option removes this temporary help container after it exits. Check the output before choosing tuning flags, because supported option names and defaults belong to the Memcached version in the image.

Check connectivity with an application client

Memcached speaks a text protocol over TCP. The most useful verification is to configure the same Memcached client library your application uses and issue a stats request or a small set/get operation. A successful response confirms both network reachability and protocol compatibility. If you use a diagnostic utility, install it deliberately in a temporary troubleshooting container or host environment; do not assume that tools such as Telnet or Netcat are present in the Memcached image.

Configure memory, connections, and threads

The default image accepts Memcached options after the image name. For example, this instance sets a 64 MB cache limit:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
docker run --name my-memcache -d memcached memcached --memory-limit=64

The value is expressed in megabytes. This limit controls cache capacity, not the amount of RAM Docker itself, the operating system, or your application may consume.

Inspect options before tuning

Start with the image’s help output:

docker run --rm memcached -h

Use that output to confirm available options and defaults for the exact image tag you deploy. Common settings documented by the official image include:

Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
  • --memory-limit=64 for a 64 MB cache.
  • --conn-limit=1024 to set the maximum number of simultaneous connections.
  • --threads=4 to configure worker threads.

For example:

docker run --name my-memcache -d memcached memcached --conn-limit=1024 --memory-limit=64 --threads=4

Do not choose these values mechanically. A larger cache limit consumes more host memory, a high connection limit allows more clients to compete for resources, and additional threads should match the workload and available CPU. Measure application behavior and keep operating-system and container memory headroom.

Keep settings readable with Compose

Compose places the image and its arguments in a file that can be reviewed and started consistently:

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.
services:
  memcached:
    image: memcached
    command:
      - --conn-limit=1024
      - --memory-limit=64
      - --threads=4

Save the file as compose.yaml, then start the service from that directory:

docker compose up -d memcached

Compose passes the list under command as arguments to the image’s normal entrypoint. Check the service and logs with:

docker compose ps memcached
docker compose logs memcached

If your Compose project includes an application service, add both services to the same default project network. The application can then use the service name memcached and port 11211.

Connect another container to Memcached

Using a user-defined network with Docker commands

  1. Create a network once:
    docker network create app-net
  2. Start Memcached on that network. No host port is needed for container-to-container traffic:
    docker run --name my-memcache --network app-net -d memcached
  3. Start your application on the same network:
    docker run --name my-app --network app-net -d your-application-image
  4. Configure the application with host my-memcache and port 11211.

Docker’s user-defined network provides name-based discovery for connected containers. The application should not use localhost: inside the application container, localhost refers to that application container itself, not Memcached.

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

Using Compose service discovery

With a Compose service named memcached, configure the application to connect to:

  • Hostname: memcached
  • Port: 11211

Port publishing is optional in this arrangement. Add a ports entry only if a host process or external client also needs access. Keeping the port internal reduces accidental exposure and avoids host-port conflicts.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Use a custom container name carefully

A manually created container can be addressed by my-memcache on its user-defined network. In Compose, prefer the stable service name rather than relying on a generated container name. This lets the application configuration remain unchanged when the project recreates the container.

Change the listening port or interface

Memcached uses TCP by default in current releases; since version 1.5.6, it listens only on TCP by default. The standard listening port is 11211. If you need a different internal port, pass the corresponding Memcached port option and map Docker’s host port to that internal port consistently. For example, using Memcached’s short port option:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
docker run --name my-memcache -d -p 127.0.0.1:11212:11212 memcached memcached -p 11212

Clients must then use port 11212. Verify the exact option with docker run --rm memcached -h for the image version you selected.

The Memcached -l option binds the daemon to selected interfaces. In a container, interface and address behavior depends on the container network, so change this only when you understand the resulting reachability. For most Docker deployments, network membership and deliberate port publishing are clearer controls than broad interface binding.

Choose an image tag deliberately

Choice Advantages Trade-offs Best fit
Unqualified memcached Debian-based default with broad compatibility and familiar tooling. It follows the registry’s current default tag, so the exact image can change over time. Local development and initial compatibility testing.
Versioned Memcached tag Makes deployments reproducible and allows controlled upgrades. You must select and maintain a version instead of receiving the moving default. Production and repeatable CI or staging environments.
Alpine variant Smaller image footprint. Uses musl libc and commonly omits tools such as Bash and Git; some software and troubleshooting workflows expect glibc or those utilities. Environments where image size is a priority and compatibility has been verified.

Pin a concrete version tag for reproducible deployments rather than relying indefinitely on latest. Record the tag in your Compose file or deployment definition and test upgrades intentionally. The Debian-based default is the safer starting point when you have not yet checked application compatibility with Alpine’s musl libc.

Understand exposure and security

Memcached should normally be reachable only by the application services that need it. The safest Docker pattern for a multi-container application is a private user-defined network with no published port. If a host process needs access, bind to 127.0.0.1. If another machine needs access, publish deliberately and enforce network-level restrictions.

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.
  • Do not assume that an un-published container port is reachable from the host; it is available to connected containers through the Docker network.
  • Do not assume that a published port is local. -p 11211:11211 binds all host interfaces unless an IP address is specified.
  • Do not place secrets or irreplaceable records in Memcached. Treat every value as disposable and reconstructable.
  • Limit which application services join the Memcached network, and avoid attaching unrelated containers to it.

Memcached is a cache layer, not an authorization boundary. Application code remains responsible for validating cached data and enforcing user permissions when values are read.

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

Operate the container safely

Stop, start, and remove it

docker stop my-memcache
docker start my-memcache
docker rm my-memcache

Stopping and starting the same container preserves its configuration, but the in-memory cache is lost when the Memcached process stops. Removing the container also removes its metadata; because the cache is volatile, there is no useful Memcached dataset to recover from a Docker volume.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

Recreate after changing settings

Docker run arguments are not edited in place. To change the memory limit, connection limit, thread count, image tag, or port mapping:

  1. Stop the existing container.
  2. Remove it with docker rm.
  3. Run a new container with the revised arguments, or update the Compose file and run docker compose up -d.
  4. Point the application at the same hostname and port, then verify connectivity.

Expect a cold cache after recreation. The application should tolerate misses while the new instance warms.

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

Use a restart policy when appropriate

For a service that should return after a Docker daemon or host restart, add a restart policy such as --restart unless-stopped to the docker run command, or configure the equivalent Compose setting. A restart policy improves availability of the process; it does not make cached data persistent or guarantee that an application can tolerate a cold cache.

Troubleshoot common failures

The name is already in use

Docker container names must be unique. If my-memcache already exists, inspect it with docker ps -a --filter name=my-memcache. Start that container if its configuration is correct, remove it and recreate it with the desired settings, or choose a different name.

Port 11211 is unavailable

Another process or container may already own the host port. Run docker port on existing containers and inspect host services. You can map a different host port while keeping Memcached’s internal port unchanged:

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

A host client must then use 127.0.0.1:11212; containers on the Docker network should continue using the container hostname and port 11211.

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

The application reports connection refused

  • Check that the container is running with docker ps.
  • Check the published mapping with docker port my-memcache if the client is on the host.
  • For container clients, confirm both containers are attached to the same user-defined network.
  • Use the Memcached container or Compose service name, not localhost, from another container.
  • Confirm that the client uses the actual listening port after any custom-port change.
  • Inspect docker logs my-memcache and verify the server started with the options you intended.

The application connects but misses every key

Check the hostname, port, key namespace, serialization format, and expiration behavior in the application. A successful TCP connection does not prove that two clients are using the same keys or compatible value encoding. Also remember that a newly started container has an empty cache by design.

The container exits immediately

Inspect the logs and run the help command to validate option names. A typo or unsupported flag can terminate the process. If you supplied a custom command, ensure it still starts the Memcached daemon rather than replacing it with a short-lived diagnostic command.

The cache is evicting entries too quickly

Use application metrics and Memcached statistics to determine whether the configured memory limit is too small for the working set. Increase the limit only when the host has sufficient memory, and review object sizes, expiration times, and key churn before simply allocating more RAM.

Local development versus production

Decision Local development Production-oriented deployment
Image reference The default memcached tag is convenient. Pin a concrete version tag and upgrade deliberately.
Network access Use no published port for container-only testing, or loopback for a host client. Keep the service on a private application network; publish only when a documented external dependency requires it.
Configuration Start with defaults and inspect options with -h. Declare memory, connection, and thread settings in Compose or deployment configuration.
Data expectations It is acceptable to lose the cache when experimenting. Applications must rebuild values from durable sources after restarts, evictions, or deployments.
Diagnostics Use docker logs, docker port, and a client probe. Monitor application hit/miss behavior, connection failures, memory pressure, and restart events.

Practical checklist

  • Start with docker run --name my-memcache -d memcached.
  • Publish 11211 only when a host or external client needs it.
  • Use 127.0.0.1:11211:11211 for host-local access; an omitted host IP binds all interfaces.
  • Use a shared user-defined network and the Memcached service name for container-to-container access.
  • Run docker run --rm memcached -h before tuning flags.
  • Declare memory, connection, and thread limits explicitly when the workload requires them.
  • Pin a version tag for reproducible deployments; choose Alpine only after checking musl and tooling compatibility.
  • Verify with docker ps, docker logs, docker port, and an application-client stats or set/get request.
  • Keep authoritative data outside Memcached and plan for a cold cache after every restart or replacement.

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.

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