I have created a bridged docker network using,
docker network create --driver bridge exa1
but when I use this network in my docker-compose and run it,
it results with this output,
ERROR: plugin "exa1" not found
I have made sure the exa1 network exists using docker network ls
and does it really exist?
Any help will be greatly appreciated!
Maybe you got a syntax error in your docker-compose.yml.
Here is my docker-compose file. Take notice on the external: true option.
version: "3"
services:
traefik:
image: traefik
container_name: traefik
command:
- --api
- --docker
- --docker.exposedbydefault=false
restart: always
ports:
- 80:80
- 8080:8080
networks:
- exa1
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
exa1:
external: true
Related
My docker-compose.yml:
version: "3"
services:
[...]
portainer:
image: portainer/portainer-ce
ports:
- "10280:9000"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "./portainer:/data"
restart: unless-stopped
command: --admin-password $$2b$$05$$XJA5Fr6FGLsptH8mb2/L2uwH2mXGDJkfbTUkpuFEnSkpWY9D2EKCO
[...]
(the "[...]" just is for other services which aren't related to the problem)
I configured the admin password with command: --admin-password [bcryptHash] but how do I configure it to use the local / "volumed" docker instance / socket from docker-compose and not from the web interface?
Try using this command
command: -H unix:///var/run/docker.sock
I found a reference to this call for the -H flag here: https://docs.portainer.io/v/ce-2.6/advanced/reverse-proxy/traefik
This contains a full docker-compose file example that sets up a reverse proxy for portainer using traefik. The relevant section is:
version: "3.3"
services:
portainer:
image: portainer/portainer-ce:2.6.3
command: -H unix:///var/run/docker.sock
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
volumes:
portainer_data:
From the official docker documentation site, there is a link to the awesome-compose repo that also has a docker-compose file example for portainer.
So from this document, it would appear that both the volume map for the socket and the command line flag are required.
I would like to translate the following docker command to a docker-compose file:
docker run -d --restart=always -v /var/run/docker.sock:/var/run/docker.sock --net shinyproxy-net -p 8080:8080 imshinyproxy
This is the docker-compose.yml that I wrote:
version: "3.7"
services:
shinyproxy:
image: imshinyproxy
container_name: imshinyproxy
environment:
- PUID=1000
- PGID=65537
- TZ=america/new_york
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 8080:8080
networks:
- shinyproxy-net
restart: unless-stopped
Alas, when I try to run docker-compose up I get the following error:
$ docker-compose up
ERROR: Service "shinyproxy" uses an undefined network "shinyproxy-net"
I know the network exist:
$ sudo docker network create shinyproxy-net
Error response from daemon: network with name shinyproxy-net already exists
What am I doing wrong?
You must declare an external network in the networks section of your docker-compose.yml :
version: "3.7"
services:
shinyproxy:
[...]
networks:
- shinyproxy-net
networks:
shinyproxy-net:
external:
name: shinyproxy-net
networks.shinyproxy-net.external.name should correspond to the name of your previously created network.
I don't how to run the docker-compose equivalent of my code
docker run -d --name=server --restart=always --net network --ip 172.18.0.5 -p 5003:80 -v $APP_PHOTO_DIR:/app/mysql-data -v $APP_CONFIG_DIR:/app/config webserver
I've done this:
version: '3'
services:
server:
image: app-dependencies
ports:
- "5003:80"
volumes:
- ./app:/app
command: python /app/app.py
restart: always
networks:
app_net:
ipv4_address: 172.18.0.5
Are you sure you need an IP address for container? It is not recommended practice, why do you want to set it explicitly?
docker-compose.yml
version: '3'
services:
server: # correct, this would be container's name
image: webserver # this should be image name from your command line
ports:
- "5003:80" # correct, but only if you need to communicate to service from ouside
volumes: # volumes just repeat you command line, you can use Env vars
- $APP_PHOTO_DIR:/app/mysql-data
- $APP_CONFIG_DIR:/app/config
command: ["python", "/app/app.py"] # JSON notation strongly recommended
restart: always
Then docker-compose up -d and that's it. You can access your service from host with localhost:5003, no need for internal IP.
For networks, I always include in the docker-compose file, the network specification. If the network already exists, docker will not create a new one.
version: '3'
services:
server:
image: app-dependencies
ports:
- "5003:80"
volumes:
- ./app:/app
command: python /app/app.py
restart: always
networks:
app_net:
ipv4_address: 172.18.0.5
networks:
app_net:
name: NETWORK_NAME
driver: bridge
ipam:
config:
- subnet: NETWORK_SUBNET
volumes:
VOLUME_NAME:
driver:local
And you will need to add the volumes separately to match the docker run command.
I am trying to set up a 2 node private IPFS cluster using docker. For that purpose I am using ipfs/ipfs-cluster:latest image.
My docker-compose file looks like :
version: '3'
services:
peer-1:
image: ipfs/ipfs-cluster:latest
ports:
- 8080:8080
- 4001:4001
- 5001:5001
volumes:
- ./cluster/peer1/config:/data/ipfs-cluster
peer-2:
image: ipfs/ipfs-cluster:latest
ports:
- 8081:8080
- 4002:4001
- 5002:5001
volumes:
- ./cluster/peer2/config:/data/ipfs-cluster
While starting the containers getting following error
ERROR ipfshttp: error posting to IPFS: Post http://127.0.0.1:5001/api/v0/repo/stat?size-only=true: dial tcp 127.0.0.1:5001: connect: connection refused ipfshttp.go:745
Please help with the problem.
Is there any proper documentation about how to setup a IPFS cluster on docker. This document misses on lot of details.
Thank you.
I figured out how to run a multi-node IPFS cluster on docker environment.
The current ipfs/ipfs-cluster which is version 0.4.17 doesn't run ipfs peer i.e. ipfs/go-ipfs in it. We need to run it separately.
So now in order to run a multi-node (2 node in this case) IPSF cluster in docker environment we need to run 2 IPFS peer container and 2 IPFS cluster container 1 corresponding to each peer.
So your docker-compose file will look as follows :
version: '3'
networks:
vpcbr:
driver: bridge
ipam:
config:
- subnet: 10.5.0.0/16
services:
ipfs0:
container_name: ipfs0
image: ipfs/go-ipfs
ports:
- "4001:4001"
- "5001:5001"
- "8081:8080"
volumes:
- ./var/ipfs0-docker-data:/data/ipfs/
- ./var/ipfs0-docker-staging:/export
networks:
vpcbr:
ipv4_address: 10.5.0.5
ipfs1:
container_name: ipfs1
image: ipfs/go-ipfs
ports:
- "4101:4001"
- "5101:5001"
- "8181:8080"
volumes:
- ./var/ipfs1-docker-data:/data/ipfs/
- ./var/ipfs1-docker-staging:/export
networks:
vpcbr:
ipv4_address: 10.5.0.7
ipfs-cluster0:
container_name: ipfs-cluster0
image: ipfs/ipfs-cluster
depends_on:
- ipfs0
environment:
CLUSTER_SECRET: 1aebe6d1ff52d96241e00d1abbd1be0743e3ccd0e3f8a05e3c8dd2bbbddb7b93
IPFS_API: /ip4/10.5.0.5/tcp/5001
ports:
- "9094:9094"
- "9095:9095"
- "9096:9096"
volumes:
- ./var/ipfs-cluster0:/data/ipfs-cluster/
networks:
vpcbr:
ipv4_address: 10.5.0.6
ipfs-cluster1:
container_name: ipfs-cluster1
image: ipfs/ipfs-cluster
depends_on:
- ipfs1
- ipfs-cluster0
environment:
CLUSTER_SECRET: 1aebe6d1ff52d96241e00d1abbd1be0743e3ccd0e3f8a05e3c8dd2bbbddb7b93
IPFS_API: /ip4/10.5.0.7/tcp/5001
ports:
- "9194:9094"
- "9195:9095"
- "9196:9096"
volumes:
- ./var/ipfs-cluster1:/data/ipfs-cluster/
networks:
vpcbr:
ipv4_address: 10.5.0.8
This will spin 2 peer IPFS cluster and we can store and retrieve file using any of the peer.
The catch here is we need to provide the IPFS_API to ipfs-cluster as environment variable so that the ipfs-cluster knows its corresponding peer. And for both the ipfs-cluster we need to have the same CLUSTER_SECRET.
According to the article you posted:
The container does not run go-ipfs. You should run the IPFS daemon
separetly, for example, using the ipfs/go-ipfs Docker container. We
recommend mounting the /data/ipfs-cluster folder to provide a custom,
working configuration, as well as persistency for the cluster data.
This is usually achieved by passing -v
:/data/ipfs-cluster to docker run).
If in fact you need to connect to another service within the docker-compose, you can simply refer to it by the service name, since hostname entries are created in all the containers in the docker-compose so services can talk to each other by name instead of ip
Additionally:
Unless you run docker with --net=host, you will need to set $IPFS_API
or make sure the configuration has the correct node_multiaddress.
The equivalent of --net=host in docker-compose is network_mode: "host" (incompatible with port-mapping) https://docs.docker.com/compose/compose-file/#network_mode
I am trying to use this image https://hub.docker.com/r/ibmcom/cloudant-developer/ with docker compose, when I use the original instructions it works, however when I translate it to docker compose format it doesn't work properly, I see the dashboard page but it is empty and seems broken.
The original run command:
docker run \
--privileged \
--detach \
--volume cloudant:/srv \
--name cloudant-developer \
--publish 8080:80 \
--hostname cloudant.dev \
ibmcom/cloudant-developer
The compose file I created:
version: '3'
services:
cloudant:
image: ibmcom/cloudant-developer:latest
container_name: cloudant-developer
hostname: cloudant.dev
ports:
- "8080:80"
expose:
- "80"
volumes:
- cloudant:/srv
privileged: true
volumes:
cloudant:
Thanks for helping.
P.S - I do executed the commands for license agreement manually
Took me a while to figure this out. Turns out the cloudant docker container is tied to the default docker network subnet. Specifically, I found that haproxy was mapped to redirect to 172.17.0.2:5984 and was failing because by default docker compose creates a new network in a different ip range. There may be other issues related to this. Ultimately I found that you could run docker compose on the default docker network with the following config:
network_mode: bridge
So, your docker-compose.yml would look like this:
version: '3'
services:
cloudant:
image: ibmcom/cloudant-developer:latest
container_name: cloudant-developer
hostname: cloudant.dev
ports:
- "8080:80"
expose:
- "80"
volumes:
- cloudant:/srv
privileged: true
network_mode: bridge
volumes:
cloudant: