I have problem with memcached in docker-compose. This is docker-compose.yml:
nginx:
container_name: nginx
image: nginx:latest
ports:
- 127.0.0.2:8000:80
volumes:
- ./htdocs:/htdocs
- ./nginx.conf:/etc/nginx/conf.d/nginx.conf
links:
- php
php:
container_name: php
build: ./php
volumes:
- ./htdocs:/htdocs
- ./php/php.ini:/usr/local/etc/php/php.ini
links:
- mysql
- memcached
mysql:
container_name: mysql
image: mysql:latest
ports:
- 127.0.0.2:8001:3306
volumes:
- ./my.cnf:/etc/mysql/my.cnf
- ./db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=db
- MYSQL_USER=root
- MYSQL_PASSWORD=root
memcached:
container_name: memcached
image: memcached:latest
ports:
- "11211:11211"
and this is my php code:
error_reporting(E_ALL & ~E_NOTICE);
$memcached = new Memcached;
$memcached->addServer('0.0.0.0', 11211);
echo '<pre>'; print_r($memcached->getServerList()); echo '</pre>';
if($memcached->getStats() === false) {
echo 'returned false';
} else {
echo '<pre>'; print_r($memcached->getStats()); echo '</pre>';
}
and result is:
Array
(
[0] => Array
(
[host] => 0.0.0.0
[port] => 11211
[type] => TCP
)
)
returned false
Why memcached cant see server? (getStats returned nothing) Command "docker ps" return list where it`s running docker memcached:lastest as port "0.0.0.0:11211->11211/tcp". Sorry for my english.
By default, UEM Server components such as DS, CN, API, and SSP talk over TCP on port 11211. When you install Memcached into your configuration, it automatically selects this port. If your network is locked down and ports must be unlocked manually, unlock port 11211 before you proceed with the installation.
Just replace host 0.0.0.0
to memcached
Host memcached
link to IP of memcached container.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With