Docker compose failed to build. There is no problem with pulling images, but fails due timeout when trying to run command like "RUN pip install pipenv". Build is possible only with adding "network: host" into docker-compose.yml. Anyway it isn't solves my problem because any atempt to send GET request fails with timeout. No idea what to do. The same problem occurs at Ubuntu 22 and Manjaro 21.
build error:
=> [6/9] RUN pip install --upgrade pip 85.7s
=> => # Requirement already satisfied: pip in /usr/local/lib/python3.9/site-packages (22.0.4)
=> => # WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.urllib3.connection.HT
=> => # TPSConnection object at 0x7f3f75f13340>, 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/pip/
request error:
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fccaa7afdc0>: Failed to establish a new connection: [Errno 110] Connection timed out'))
You may create a custom network with a defined subnet:
version: '3'
services:
web:
build:
context: .
network: custom_network
networks:
custom_network:
ipam:
driver: default
config:
- subnet: "192.168.100.1/28"
Try this out, I hope this will help.
Related
I use the default file generated by CookieCutter:
...
pytest:
stage: test
tags:
- docker
image: docker/compose:1.29.2
services:
- docker:dind
before_script:
- docker-compose -f local.yml build
# Ensure celerybeat does not crash due to non-existent tables
- docker-compose -f local.yml run --rm django python manage.py migrate
- docker-compose -f local.yml up -d
script:
- docker-compose -f local.yml run django pytest
only:
- main
The linting stage with flake8 run perfectly fine, but the testing stage seem to have some issue with Docker:
Using docker image sha256:32d8a4638cd83922fdd94cadf4f1850b595d29757488c73adf05f4b99ebd1318 for docker/compose:1.29.2 with digest docker/compose#sha256:ae66070588c539b965986dc74e9371e3e62ef71668b72a5eed70de111ed3659e ...
$ docker-compose -f local.yml build
[32] Failed to execute script docker-compose
Traceback (most recent call last):
File "urllib3/connection.py", line 160, in _new_conn
File "urllib3/util/connection.py", line 84, in create_connection
File "urllib3/util/connection.py", line 74, in create_connection
ConnectionRefusedError: [Errno 111] Connection refused
...
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x4004373b50>: Failed to establish a new connection: [Errno 111] Connection refused
...
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='docker', port=2375): Max retries exceeded with url: /version (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x4004373b50>: Failed to establish a new connection: [Errno 111] Connection refused'))
...
It looks like it can't connect to Docker daemon. I've tried to add variable DOCKER_HOST to something like tcp://localhost:2375, tcp://host.docker.internal:2375 but the problem still remains.
I have python flask application that listens to another microservice running on 8080. When I run as flask application it is able to get from http://localhost:8080/users.
But when I run inside docker it fails with
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /users (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f53804b5dc0>: Failed to establish a new connection: [Errno 111] Connection refused'))
at line:
File "/alert.py", line 45, in get_users
r = requests.get('http://localhost:8080/users',verify=False)
This is my main code:
if __name__ == '__main__':
app.logger.setLevel(logging.INFO)
data = create_data()
port = os.getenv('PORT')
app.run(debug=True, host='0.0.0.0', port=port)
Docker script:
#!/bin/bash
docker build -t covid_service .
docker run -p 5000:5000 covid_service
Docker file:
FROM python:3
ADD alert.py /
RUN pip install flask
RUN pip install requests
EXPOSE 5000
CMD [ "python", "./alert.py" ]
Any help please
equests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /users (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f53804b5dc0>: Failed to establish a new connection: [Errno 111] Connection refused'))
You can not access another container using localhost, localhost mean flask app container not another microservice.
change the localhost to something HOST_IP on Linux or use host.docker.internal for window and mac.
r = requests.get('http://host.docker.internal:8080/users',verify=False)
port = os.getenv('PORT')
You are not receiving port here, because Dockerfile and start command do not contain it.
Either edit Dockerfile - add
ENV PORT=5000
or add -env PORT=5000 to start command
If you need reach service that working in docker and using your Docker file, you should query http://localhost:5000/users
I facing an issue on my Molecule Test. I have begin to study this tool 2 days ago for information.
on a Ubuntu VM running with Vagrant,I have create a role and initialze Molecule's folder and create a testinfra test file ( with the docker provider ).
The error is when my task's role are running, at the step of checking service running, it failed.
fatal: [instance]: FAILED! => {"changed": false, "msg": "Could not find the requested service httpd: "}
I was design to simply install 2 packages including httpd on a Centos Image.
When im loggin directly to the Molecule VM ( so through docker ), when i simply type systemctl the error message is
Failed to get D-Bus connection: Operation not permitted
As adviced Geerlingguy, i have specify volume mapped on cgroup folder
platforms:
- name: instance
#image: docker.io/pycontribs/centos:7
image: geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
The error is not related to Testinfra but only the docker built image.
Could someone help me to understand why this error message ?
Is that because im on a VirtualBox ran by Vagrant ?
Thanks all for reading :-)
I have added that on my mocule.yml file config according molecule documentation ( https://molecule.readthedocs.io/en/latest/examples.html#docker ) :
platforms:
- name: instance
#image: docker.io/pycontribs/centos:7
image: geerlingguy/docker-centos7-ansible:latest
capabilities:
- SYS_ADMIN
command: /sbin/init
systemctl working fine now
I am having issues when trying to connect to a docker-compose network from inside of a container. These are the files I am working with. The whole thing runs when I ./run.sh.
Dockerfile:
FROM docker/compose:latest
WORKDIR .
# EXPOSE 8228
RUN apk update
RUN apk add py-pip
RUN apk add jq
RUN pip install anchorecli
COPY dockertest.sh ./dockertest.sh
COPY docker-compose.yaml docker-compose.yaml
CMD ["./dockertest.sh"]
docker-compose.yaml
services:
# The primary API endpoint service
engine-api:
image: anchore/anchore-engine:v0.6.0
depends_on:
- anchore-db
- engine-catalog
#volumes:
#- ./config-engine.yaml:/config/config.yaml:z
ports:
- "8228:8228"
..................
## A NUMBER OF OTHER CONTAINERS THAT ANCHORE-ENGINE USES ##
..................
networks:
default:
external:
name: anchore-net
dockertest.sh
echo "------------- INSTALL ANCHORE CLI ---------------------"
engineid=`docker ps | grep engine-api | cut -f 1 -d ' '`
engine_ip=`docker inspect $engineid | jq -r '.[0].NetworkSettings.Networks."cws-anchore-net".IPAddress'`
export ANCHORE_CLI_URL=http://$engine_ip:8228/v1
export ANCHORE_CLI_USER='user'
export ANCHORE_CLI_PASS='pass'
echo "System status"
anchore-cli --debug system status #This line throws error (see below)
run.sh:
#!/bin/bash
docker build . -t anchore-runner
docker network create anchore-net
docker-compose up -d
docker run --network="anchore-net" -v //var/run/docker.sock:/var/run/docker.sock anchore-runner
#docker network rm anchore-net
Error Message:
System status
INFO:anchorecli.clients.apiexternal:As Account = None
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 172.19.0.6:8228
Error: could not access anchore service (user=user url=http://172.19.0.6:8228/v1): HTTPConnectionPool(host='172.19.0.6', port=8228): Max retries exceeded with url: /v1
(Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))
Steps:
run.sh builds container image and creates network anchore-net
the container has an entrypoint script, which does multiple things
firstly, it brings up the docker-compose network as detached FROM inside the container
secondly, nstalls anchore-cli so I can run commands against container network
lastly, attempts to get a system status of the anchore-engine (d.c network) but thats where I am running into HTTP request connection issues.
I am dynamically getting the IP of the api endpoint container of anchore-engine and setting the URL of the request to do that. I have also tried passing those variables from command line such as:
anchore-cli --u user --p pass --url http://$engine_ip/8228/v1 system status but that throws the same error.
For those of you who took the time to read through this, I highly appreciate any input you can give me as to where the issue may be lying. Thank you very much.
OS: Centos 7
Docker version 17.03.0-ce, build 60ccb22
docker-compose version 1.11.2, build dfed245
I need to map a large range of ports (40000-60000/udp) for RED5Pro server but i always get this error when creating the image:
ERROR: for red5pro UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
ERROR: An HTTP request took too long to complete. Retry with --verbose to obtain debug information.
If you encounter this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value (current value: 60).
here is the compose file
version: '2'
services:
red5pro:
build: ./red5pro/
container_name: red5pro
ports:
- "5080:5080"
- "1935:1935"
- "8554:8554"
- "6262:6262"
- "8081:8081"
- "40000-60000:40000-60000/udp"
and the Dockerfile
FROM java:8
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y \
libva1 \
libva-drm1 \
libva-x11-1 \
libvdpau1
WORKDIR /opt/red5pro <br>COPY / /opt/red5pro/
ENTRYPOINT ["sh","/opt/red5pro/red5.sh"]
On Mac, what I did was going to the docker icon (upper right corner) and clicked restart, maybe is not the best solution, but it´s the fastest one