How do I tell CircleCI and docker-compose to run Redis with persistent storage? I expected to see something like docker run -d -p 6379:6379--name redis dockerfile/redis in circle.yml where I can add a -v <data-dir>:/data to, but I only see redis listed under services: in circle.yml:
machine:
services:
- redis
node:
version: 6.3.0
python:
version: 3.5.2
# ...deployment commands follow, but no redis
Related
I am trying to build service from docker file when start docker compose. The docker-compose.yml looks like:
version: '3'
services:
app:
build:
context: .
shm_size: 4gb
# ...
The build process need to enable GPU. I know how to enable GPU in deploy according to this blog. But it seems docker compose file build do not support GPU.
I think, I have read two different method.
The simple, try that:
https://docs.docker.com/compose/gpu-support/
https://www.tremplin-numerique.org/en/how-to-run-compose-docker-containers-with-gpu-access
services:
test:
image: nvidia/cuda:10.2-base
command: nvidia-smi
runtime: nvidia
The complex,
It run a docker via a run.
Then via docker compose, it connect to its docker.
In this method, it describes all steps.
https://dinhanhthi.com/docker-gpu/
docker run \
--gpus all\
--name docker_thi_test\
--rm\
-v abc:abc\
-p 8888:8888
Yaml
version: '2'
services:
jupyter:
container_name: 'docker_thi_test'
build: .
volumes:
- ./notebooks:/tf/notebooks
ports:
- 8888:8888
environment:
- NVIDIA_VISIBLE_DEVICES=0
- PASSWORD=12345
I am running through a problem where I can't mount Unix docker socket to an alpine container but works with ubuntu container.
docker-compose using alpine image
version: '3.8'
services:
cluster:
image: alpine
tty: true
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "/usr/bin/docker:/usr/bin/docker"
running docker command in the alpine container:
/ # docker --version
sh: docker: not found
docker-compose using ubuntu image
version: '3.8'
services:
cluster:
image: ubuntu:20.04
tty: true
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "/usr/bin/docker:/usr/bin/docker"
running docker command in the ubuntu container:
root#5f30b4143c43:/# docker --version
Docker version 20.10.12, build e91ed57
I don't get why I can access my host docker env using the ubuntu container but not with the alpine one? is there anything missing in the configuration?
Your error has nothing to do with the socket:
/ # docker --version
sh: docker: not found
You're seeing this because you're trying to run a binary compiled for glibc platform, while Alpine is built using MUSL libc.
You would need to install a version of the docker client built specifically for use under Alpine (or just pick almost any other image).
I created a minimal docker-compose.yml file, something like this
version: '3.7'
services:
odoo:
image: odoo:14.0
container_name: odoo-app
restart: always
command:
--without-demo all
then create a new docker context using
sudo docker context create remote --docker "host=ssh://root#my-remote.server.com:2222"
i can see the new created context using
sudo docker context ls
i can connect to ssh without problem
When i try to run this deployment nothing happen
(venv) augusto#augusto-NUC10i7FNH:~/Progetti/odoo$ sudo docker-compose --verbose --context remote -f docker-compose.yml -f docker-compose.prod.yml up -d
compose.config.config.find: Using configuration files: ./docker-compose.yml,./docker-compose.prod.yml
(venv) augusto#augusto-NUC10i7FNH:~/Progetti/odoo$
why?
Both hosts (local and remote server) have Ubuntu 20.04 and the same version of docker-compose
docker-compose version 1.28.2, build unknown
docker-py version: 4.4.1
CPython version: 3.8.5
OpenSSL version: OpenSSL 1.1.1f 31 Mar 2020
I have a docker compose file that links my server to a redis image:
version: '3'
services:
api:
build: .
command: npm run dev
environment:
NODE_ENV: development
volumes:
- .:/home/node/code
- /home/node/code/node_modules
- /home/node/code/build/Release
ports:
- "1389:1389"
depends_on:
- redis
redis:
image: redis:alpine
I am wondering how could I open a redis-cli against the Redis container started by docker-compose to directly modify ke/value pairs. I tried with docker attach but it does not open any shell.
Use docker exec -it your_container_name /bin/bash to enter into redis container, then execute redis-cli to modify key-value pair.
See https://docs.docker.com/engine/reference/commandline/exec/
Install the Redis CLI on your host. Edit the YAML file to publish Redis's port
services:
redis:
image: redis:alpine
ports: ["6379:6379"]
Then run docker-compose up to redeploy the container, and you can run redis-cli from the host without needing to directly interact with Docker.
Using /bin/bash as the command (as suggested in the accepted solution) doesn't work for me with the latest redis:alpine image on Linux.
Instead, this worked:
docker exec -it your_container_name redis-cli
Using the official redmine docker guide it is possible to start a redmine server connected to a postgresql database. I used the following commands:
docker run -d --name redmine_db -p 6543:5432 -e POSTGRES_PASSWORD=secret -e POSTGRES_USER=redmine postgres:9.5.1
docker run -d --name redmine_web -p 3001:3000 --link redmine_db:postgres redmine:3.2.3
But I have difficulties to run the same configuration with docker compose. Here is the first docker-compose.yml file I used:
version: '2'
services:
webserver:
image: redmine:3.2.3
ports:
- "3001:3000"
links:
- database:postgres
database:
image: postgres:9.5.1
ports:
- "6543:5432"
environment:
- POSTGRES_PASSWORD="secret"
- POSTGRES_USER="redmine"
With docker compose the redmine server starts correctly but it ignores the postgres database container and uses the internal SQLite database instead.
I've also tried with the following environments in the webserver configuration:
environment:
- POSTGRES_PORT_5432_TCP="5432"
- POSTGRES_ENV_POSTGRES_USER="redmine"
- POSTGRES_ENV_POSTGRES_PASSWORD="secret"
But without success. This time the redmine container does not start at all and displays the following error message:
[!] There was an error parsing `Gemfile`: (<unknown>): did not find expected key while parsing a block mapping at line 2 column 3. Bundler cannot continue.
# from /usr/src/redmine/Gemfile:64
# -------------------------------------------
# if File.exist?(database_file)
> database_config = YAML::load(ERB.new(IO.read(database_file)).result)
# adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
# -------------------------------------------
From docker-compose version 2 docs:
links with environment variables: As documented in the environment
variables reference, environment variables created by links have been
deprecated for some time. In the new Docker network system, they have
been removed. You should either connect directly to the appropriate
hostname or set the relevant environment variable yourself, using the
link hostname:
web:
links:
- db
environment:
- DB_PORT=tcp://db:5432
In docker-compose v. 2 you should use networks instead. All services in docker-compose in one common network by default. In your config your webserver container can resolve database by database host without any links.