How to find the right version of my docker-compose - docker

How do I find the right compose file version for my docker-compose.yml file?
I have this:
version: '3.7'
services:
ghost:
container_name: ghost
image: ghost:latest
restart: always
ports:
- 127.0.0.1:2368:2368
volumes:
-v /var/www/myBlog/:/var/lib/ghost
and I have installed Docker Engine - Community version: 19.03.8
How can I know it?
Thanks

Are you sure about the -v under your volumes?
Please check the #volume-configuration-reference for docker-compose files.
You need to mention it like below.
volumes:
- /var/www/myBlog/:/var/lib/ghost

You need to change the volume to below
volumes:
- /var/www/myBlog/:/var/lib/ghost
There is a compatibility matrix between Docker Engine and docker-compose
https://docs.docker.com/compose/compose-file/compose-versioning/
Below is the changelog of docker-compose and docker which can help you understand various features available in which version.
Docker-compose:- https://github.com/docker/compose/blob/master/CHANGELOG.md
Docker-ce:- https://github.com/docker/docker-ce/releases

Related

Jenkins in ubuntu

I'm using docker-compose to mount a volume on an image. I have the container running, but not able to pull the image in the browser.
Docker-compose has these below lines -
version: '2'
services:
jenkins:
image: image_name
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/gp_oes/project/jenkins_home:/var/jenkins_home
ports:
- 8080
I think you are trying to download the official image of ubuntu (https://hub.docker.com/_/jenkins) which was deprecated since last 2 years.
Please check with the community image of jenkins (https://hub.docker.com/r/jenkins/jenkins)
if it is not the case please provide error with command and image name also to give better understanding of the question.

docker-compose.yml volumes is not mounted to the target container

Ater too much googling I can't find a solution.
My docker-compose.yml file
version: '2'
services:
system:
build: .
container_name: apo_api
volumes:
- ./:/var/www/html
ports:
- '1122:80'
The container builds and runs successfully but the /var/www/html folder is empty when sshed into the container.
Any kind of help is appreciated. Thank you very much
OS: Ubuntu 20.04
Docker version: 19.03.13

Docker stack deploy multiple errors from container on docker hub

I'm new to docker and trying to understand what docker stack does. Currently trying out this container https://hub.docker.com/r/instapy/instapy
this is the docker-compose file
services:
web:
image: instapy/instapy:latest
container_name: "${COMPOSE_PROJECT_NAME}_web"
env_file: .env
environment:
- PYTHONUNBUFFERED=0
- INSTAPY_WORKSPACE=/code/InstaPy
volumes:
- ./:/code
The errors I'm getting seem to indicate quite a few issues
Ignoring deprecated options:
container_name: Setting the container name is not supported.
service "web": container_name is deprecated
service "web": env_file are ignored
Stack.compose.docker.com "test" is invalid: test: Invalid value: "null": conversion to kube entities failed: C:\Users\roole\instapy-docker\docker-compose: only absolute paths can be specified in mount source
docker compose version info
docker-compose version 1.24.1, build 4667896b
docker-py version: 3.7.3
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.0.2q 20 Nov 2018
Content asked for from ' docker-compose config'
services:
web:
container_name: instapy_web
environment:
COMPOSE_PROJECT_NAME: instapy
INSTAPY_WORKSPACE: /code/InstaPy
PYTHONUNBUFFERED: '0'
image: instapy/instapy:latest
volumes:
- C:\Users\roole\instapy-docker\docker-compose:/code:rw
version: '3.0'
Any help in understanding what the hell I'm supposed to be doing would be mega.
At the beginning of each docker-compose.yml file you need to specify the version. Each version of docker-compose supports certain versions of the yml file specification.
This should work for you:
version: "3.3"
services:
web:
image: instapy/instapy:latest
container_name: "${COMPOSE_PROJECT_NAME}_web"
env_file: .env
environment:
- PYTHONUNBUFFERED=0
- INSTAPY_WORKSPACE=/code/InstaPy
volumes:
- ./:/code
When deploying a stack the container name is not relevant (in fact after version "3" is not supported). The reason for that is that docker needs to be able to change the container name in case you scale your service (multiple versions of the same container might end up running on the same docker instance and then they need to have different container names).
Also when you specify a volume you need to specify full, absolute paths. You can simply replace your volume declaration with what you got from running docker-compose config (C:\Users\roole\instapy-docker\docker-compose:/code:rw) or you can use $PWD or the equivalent for your OS to refer to your current directory

How to Share a Docker-Compose Volume in Distributed Cassandra Container using Docker

I have configured distributed version of cassandra using Docker-Compose.
Here is my docker-compose.yml file:
version: '3.0'
services:
cassandra-masters:
image: strapdata/elassandra
environment:
CASSANDRA_LISTEN_ADDRESS: tasks.cassandra-masters
cassandra-slaves1:
image: strapdata/elassandra
environment:
CASSANDRA_SEEDS: tasks.cassandra-masters
CASSANDRA_LISTEN_ADDRESS: tasks.cassandra-slaves1
depends_on:
- cassandra-masters
After running the docker-compose file using sudo docker stack deploy elassandra --compose-file docker-compose.yml, everything works well and I can see them using docker service ls command.
Problem: What I want is that I don't know how to use volume in distributed of containers. Is it like the normal configuration of docker-compose that found in Docker's site? or it is different?
Solution I have tried the named volumes like the following, There isn't any difference between this approach (distributed) and normal approach. The only thing that should be considered is that the volume should be shared:
version: '3.0'
services:
cassandra-masters:
image: strapdata/elassandra
environment:
CASSANDRA_LISTEN_ADDRESS: tasks.cassandra-masters
volumes:
- app-volume:/var/lib/cassandra
cassandra-slaves1:
image: strapdata/elassandra
environment:
CASSANDRA_SEEDS: tasks.cassandra-masters
CASSANDRA_LISTEN_ADDRESS: tasks.cassandra-slaves1
depends_on:
- cassandra-masters
volumes:
- app-volume:/var/lib/cassandra
volumes:
app-volume:

Unable to use Docker Compose 3.5 Features

So I'm trying to setup some docker-compose scripts using some of the latest compose 3.5 features. The big one is being able to name networks. So there are some containers that I end up reproducing over and over again, such as a Postgres database, with various apps I work on. My goal is to be able to have a docker-compose script for something like Postgres, with a named network, which I can then have other apps with their own docker-compose scripts just add on to. It feels more re-usable that way.
Anyway, here is the docker-compose script I'm working with:
version: '3.5'
services:
postgres:
image: postgres:11
container_name: postgres
networks:
- pg_network
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_USER=user
ports:
- 5432:5432
volumes:
- ~/.postgresql/data:/var/lib/postgresql/data
- ~/.postgresql/init:/docker-entrypoint-initdb.d
pgadmin:
image: dpage/pgadmin4
container_name: pgadmin
networks:
- pg_network
ports:
- 5433:80
environment:
- PGADMIN_DEFAULT_EMAIL=user#gmail.com
- PGADMIN_DEFAULT_PASSWORD=password
volumes:
- ~/.postgresql/pgadmin:/var/lib/pgadmin
networks:
pg_network:
name: pg_network
I am trying to use the "custom name" feature new in Docker Compose 3.5. See this link for the documentation: https://docs.docker.com/compose/networking/
However, when I try to run docker-compose up -d, I get the following error:
ERROR: The Compose file './docker-compose.yml' is invalid because:
networks.pg_network value Additional properties are not allowed ('name' was unexpected)
I'm not sure what I'm doing wrong. I'm on Ubuntu 18.04, I'm running the docker commands with sudo (because that seems to be a requirement on Ubuntu).
Here are my Docker and Docker Compose versions:
Docker version 18.09.2, build 6247962
docker-compose version 1.17.1, build unknown
I've tried upgrading them with APT, but it says they are up to date.
So, either I'm making a mistake in my compose script, or there's something screwy with my Docker version. I would appreciate any insight that can be offered. Thank you.

Resources