127.0.0.1:11211 is down party_manager | DalliError: No server available
127.0.0.1:11211 is down party_manager | DalliError: No server available
我正在使用 docker。每当我的应用程序尝试读取或写入缓存时,它都会出现以下错误:
Cache read: send_otp_request_count_3
Dalli::Server#connect 127.0.0.1:11211
127.0.0.1:11211 failed (count: 0) Errno::ECONNREFUSED:
Connection refused - connect(2) for "127.0.0.1" port 11211
DalliError: No server available
我的 Gemfile 有:
gem 'dalli'
我的 Dockerfile 是:
FROM ruby:2.3.6
RUN mkdir -p /railsapp
WORKDIR /railsapp
RUN apt-get update && apt-get install -y nodejs --no-install-recommends
RUN apt-get update && apt-get install -y mysql-client --no-install-recommends
COPY Gemfile /railsapp/
COPY Gemfile.lock /railsapp/
RUN bundle install
COPY . /railsapp
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]
我的 docker-compose.yml 文件是:
version: '3.3'
services:
cache:
image: memcached:1.4-alpine
mysql:
image: mysql
restart: always
ports:
- "3002:3002"
volumes:
- /var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=dev
web:
container_name: party_manager
build:
context: .
dockerfile: Dockerfile
environment:
- RAILS_ENV=development
ports:
- '3000:3000'
volumes:
- .:/railsapp
links:
- mysql
我还通过
在容器shell中安装了memchaced
docker exec -it 499e3d1efe44 bash
**499e3d1efe44 是我的容器 ID。
然后使用命令安装 gem:gem install memcached
By default Compose sets up a single network for your app. Each
container for a service joins the default network and is both
reachable by other containers on that network, and discoverable by
them at a hostname identical to the container name.
因此,根据您的 docker-compose.yaml
文件,您可以从 Web 容器访问 cache:112111
上的缓存容器。
我正在使用 docker。每当我的应用程序尝试读取或写入缓存时,它都会出现以下错误:
Cache read: send_otp_request_count_3
Dalli::Server#connect 127.0.0.1:11211
127.0.0.1:11211 failed (count: 0) Errno::ECONNREFUSED:
Connection refused - connect(2) for "127.0.0.1" port 11211
DalliError: No server available
我的 Gemfile 有:
gem 'dalli'
我的 Dockerfile 是:
FROM ruby:2.3.6
RUN mkdir -p /railsapp
WORKDIR /railsapp
RUN apt-get update && apt-get install -y nodejs --no-install-recommends
RUN apt-get update && apt-get install -y mysql-client --no-install-recommends
COPY Gemfile /railsapp/
COPY Gemfile.lock /railsapp/
RUN bundle install
COPY . /railsapp
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]
我的 docker-compose.yml 文件是:
version: '3.3'
services:
cache:
image: memcached:1.4-alpine
mysql:
image: mysql
restart: always
ports:
- "3002:3002"
volumes:
- /var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=dev
web:
container_name: party_manager
build:
context: .
dockerfile: Dockerfile
environment:
- RAILS_ENV=development
ports:
- '3000:3000'
volumes:
- .:/railsapp
links:
- mysql
我还通过
在容器shell中安装了memchaceddocker exec -it 499e3d1efe44 bash
**499e3d1efe44 是我的容器 ID。
然后使用命令安装 gem:gem install memcached
By default Compose sets up a single network for your app. Each container for a service joins the default network and is both reachable by other containers on that network, and discoverable by them at a hostname identical to the container name.
因此,根据您的 docker-compose.yaml
文件,您可以从 Web 容器访问 cache:112111
上的缓存容器。