Docker: Error response from daemon: Could not get container for data

AI-generated summary

In a self-hosting discussion about Docker errors, ariadoss reported an issue bootstrapping Discourse on Ubuntu 14.04 (AWS EC2) using web_only.yml, encountering the error: “Could not get container for data.” The error occurred because the data container (which holds the database) was not running before attempting to bootstrap web_only. ariadoss resolved it by switching to standalone.yml and configuring remote PostgreSQL and Redis, which worked without issue. itamerlanium asked for clarification, and SKoschnicke explained that in multi-container setups, the data container must be started first (./launcher start data) before bootstrapping the web container. The error arises when the web container tries to connect to a non-running or nonexistent database container. SKoschnicke also referenced a related Meta Discourse thread discussing the requirement for Redis and PostgreSQL connections during Docker image builds here.

OS: Ubuntu 14.04
Setup: AWS, EC2 with Ubuntu 14.04, Redis on ElastiCache, and PostgreSQL on RDS
Docker version: 1.10.1

Error Message:

root@ip-10-0-3-99:/var/discourse# ./launcher bootstrap web_only
cd /pups && git pull && /pups/bin/pups --stdin
docker: Error response from daemon: Could not get container for data.
See '/usr/bin/docker run --help'.
cat: cids/web_only_bootstrap.cid: No such file or directory
docker: "rm" requires a minimum of 1 argument.
See '/usr/bin/docker rm --help'.

Usage:	docker rm [OPTIONS] CONTAINER [CONTAINER...]

Remove one or more containers
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one

Instead of using web_only.yml I switched to standalone.yml and added a remote DB and redis config to it. This worked perfectly.

Could you explain it in details, I’ve experienced with the same issue? :slight_smile:

I think that happens when trying to bootstrap the app in multi-container mode (i.e. not using the standalone.yml config but the web_only.yml and data.yml or any other config which doesn’t setup database and webapp in the same container.

After bootstrapping the container with the database (e.g. ./launcher bootstrap data), you have to start the database container before you can bootstrap the web container (e.g. ./launcher start data before ./launcher bootstrap web_only).

If there is no database access when bootstrapping the web app, you get this (rather hard to understand) error message.

See also Isn't it weird that you can't build docker image without Redis and Postgres connection?