I am having problems setting up memcached on my docker. I get an error when I run: docker run –name=memcache -p 11211:11211 -d memcached memcached -m 128
This is the error that comes after running the command above
docker: Error response from daemon: driver failed programming external connectivity on endpoint memcache (9f4bd30f7253ee185f6a160ef8e89d3f3c2d46f0361ec15f11a6975477c19430): Error starting userland proxy: listen tcp 0.0.0.0:11211: bind: address already in use.
In the end it says the port chosen is taken already. So to confirm that memcached doesn't listen on any ports I ran "docker ps -a", and this was the output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
116acff4b1aa memcached "docker-entrypoint.s…" 10 minutes ago Created memcache
a4e1a6168bca staticwebserver:v3 "/init.sh" 2 weeks ago Up 16 hours 0.0.0.0:8002->80/tcp lucid_mccarthy
a27174f8a988 staticwebserver:v3 "/init.sh" 2 weeks ago Up 16 hours 0.0.0.0:8001->80/tcp thirsty_shockley
As I can't see that the container(memcached) listens to any ports I wanted to see what process is already listening on port 11211. So I ran netstat -pna | grep 11211
tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 5703/memcached
Here I am confused, does memcached work? Or is something wrong?
I tried to kill the deamon, but it pops up again the second I kill it.
Best Answer
You appear to be running an instance of memcached outside of a container on the same port. You'll need to either stop that outside instance, or pick a different port to publish n the host. For stopping the outside instance, that depends on how you've been starting it, perhaps it's in systemd. You can work from the process id and look for parent pids until you find what's starting it, or pull up the process tree with
ps axjf
.