I am learning the docker , but don't know where i am going wrong.
Running the following command for the creating the Image from the Dockerfile:
Command: I am inside the the terminal where project is located and running below command:
docker build -f Dockerfile -t spring-boot-docker-ex .
Error Message:
time="2020-02-02T11:23:46+05:30" level=error msg="failed to dial gRPC: unable to upgrade to h2c, received 500"
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpuse
tmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&session=rveuxbqxdbzktl94h1jxp2s26&shmsize=0&t=docker_test&target=&
ulimits=null&version=1: context canceled
DockerFile:
FROM openjdk:latest
ADD target/dockerlearn-0.0.1-SNAPSHOT.jar dockerlearn.jar
ENTRYPOINT ["java","-jar","dockerlearn.jar"]
EXPOSE 8080
Related
Installed Versions
Application
Version
Docker
19.03.6, build 369ce74a3c
Docker Compose
v2.13.0
OS
Ubuntu 18.04.2 LTS
Docker definitions
docker-compose.yml
version: "2.3"
services:
builder:
build:
context: ./
dockerfile: Dockerfile
args:
- NODE_VERSION=${NODE_VERSION:-12.22.7}
image: redacted/node:${NODE_VERSION}
volumes:
- ./:/code
environment:
- BUILDKIT_PROGRESS=plain
.env
CLIENT=${CLIENT_PREFIX:-xx}
PUBLIC_URL=/${CLIENT}-dashboard
REACT_APP_NODEJS_SERVER=${CLIENT}-server
NODE_VERSION=12.22.7
Dockerfile
ARG NODE_VERSION="12.22.7"
FROM node:${NODE_VERSION}
VOLUME ["/code"]
WORKDIR /code
CMD "/code/build_ui.sh"
Issue description
Our project requires multiple versions of node & npm installed. To avoid compatibility issues, we are trying to use docker to stabilize the versions we need.
We use the below command to run the build for our application:
docker-compose run --rm builder
This works on some of our servers, but on some servers, I get either of the below errors:
failed to solve: failed to solve with frontend dockerfile.v0: failed to build llb: failed to load cache key: rpc error: code = unknown desc = error getting credentials - err: exit status 1, out: cannot autolaunch d-bus without x11 $display ubuntu.
Fixed this by following the guide here. However, given that I was trying to pull node and that is a public repo, I don't understand why docker was attempting a login. And why didn't this happen on all servers?
docker run Error response from daemon: No command specified
Fixed this temporarily by manually building the image using docker build command. But I really want the docker-compose to be able to build the image if the image doesn't exist.
I was expecting docker-compose to build the image on first run without issues and run the build_ui.sh on container execution.
When I get the above errors, if I manually build the docker image (and not wait for docker-compose to build it) using the below command, and then use the docker-compose run command it works.
docker build -t redacted/node:12.22.7 .
I am trying to figure out why docker-compose is not building the image correctly when the image doesn't exist.
I have built my custom frontend image
FROM node:16-alpine3.16
WORKDIR /usr/src/app
COPY . .
EXPOSE 4200
CMD ["npm", "run", "start"]
Than I run it with docker compose
docker compose up frontend-app --build
Image running and working as expected.
Than I run it with docker compose without --build flag
docker compose up frontend-app
Image running and working as expected.
But when I disable wi-fi (internet), and run previous command again with --build flag, it shows me an error:
=> ERROR [internal] load metadata for docker.io/library/node:14.15.5-alpine3.10 0.1s
------
> [internal] load metadata for docker.io/library/node:14.15.5-alpine3.10:
------
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to do request: Head "https://registry-1.docker.io/v2/library/node/manifests/14.15.5-alpine3.10": Failed to lookup host: registry-1.docker.io
What is the point always check for the node updates if node already dowloaded, and even pulled separatly from docker image?
Next command shows that this image localy already exists:
docker pull node:14.15.5-alpine3.10
14.15.5-alpine3.10: Pulling from library/node
b038bcb63e9c: Already exists
2ad96160a6c4: Already exists
694a34677dcf: Already exists
253b9b23d1bc: Already exists
Digest: sha256:fd87531f9bf187273c77ad3ddd5067110ef983f998fc2ea1b9932950df78bd8c
Status: Downloaded newer image for node:14.15.5-alpine3.10
docker.io/library/node:14.15.5-alpine3.10
Using --build you are building again the image, why do you use it if you already have the image?
Use just docker-compose down & docker-compose-up
I have a web service that is packed inside Docker image. I use compose to build this image and run it. I use docker desktop to run docker containers.
So, to run service I just need to type:
docker-compose run app
compose file:
version: "3.6"
services:
app:
build:
context: .
target: app
ports
- 5001:5001
docker file:
FROM python:3.10-slim as app
RUN mkdir -p /app
WORKDIR /app
COPY entrypoint.sh .
CMD ["sh", "/app/entrypoint.sh"]
However, I face following issue: when I try to get this service GET http://localhost:5001/up I get Error: connect ECONNREFUSED
I can't figure out why I can't access service. Any help/comment/explanation will be mush appreciated.
Did you check if the docker is running using the command docker ps ?
If it's running, please check if the port is listening using netstat -tnulp | grep 5001
Also check if firewall is blocking the connection
I want to deploy container group to Azure Container Instances from bitbucket pipelines. I have following bitbucket-pipelines.yml file:
image: ubuntu:20.04
clone:
depth: 5
options:
max-time: 15
pipelines:
branches:
master:
- step:
name: Deploy to aci
deployment: test
script:
- apt-get update
- apt-get install curl -y
- curl -L https://raw.githubusercontent.com/docker/compose-cli/main/scripts/install/install_linux.sh | sh
- curl -sSL https://github.com/docker/compose-cli/releases/download/v2.0.0-beta.3/docker-compose-linux-amd64 -o docker-compose
- chmod +x docker-compose
- mkdir -p ~/.docker/cli-plugins
- mv docker-compose ~/.docker/cli-plugins/docker-compose
- docker login azure --client-id $CLIENTID --tenant-id $TENANTID --client-secret $SECRET
- docker login myregistry.azurecr.io -u $USERNAME -p $PASS
- docker context create aci myContext --subscription-id "00000000-0000-0000-0000-000000000000" --resource-group "myResouceGroup" --location "westeurope"
- docker --context myContext compose up
services:
- docker
I am getting following error on docker --context myContext compose up command:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
All other docker command seems to be working so it's seems to be problem with docker-compose cli that it doesn't find the deamon running.
I tried adding export DOCKER_HOST="tcp://0.0.0.0:2375" before docker compose up but it didn't help.
Is there something I am missing?
UPDATE 1:
If I update last command from:
- docker --context myContext compose up
To:
- docker context use myContext
- docker compose up
I am getting different error:
failed to dial gRPC: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing unable to upgrade to h2c, received 403"
UPDATE 2
Added docker version and docker ps for more info. Output:
docker version
Client: Docker Engine - Community
Cloud integration: 1.0.17
Version: 19.03.15
API version: 1.40
...
Server: Docker Engine - Community
Engine:
Version: 20.10.5
API version: 1.41 (minimum version 1.12)
...
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Is the docker daemon running? is a common error caused by s.o permissions, docker-in-docker, etc. Also this error is not related to docker-compose.
In your case, you are executing docker commands inside of a docker container, so try to add this at the beginning of your pipeline:
options:
docker: true
Check these solutions for Is the docker daemon running? error:
Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?
How to connect to docker daemon in Bitbucket pipeline
https://github.com/docker/for-linux/issues/535
https://forums.docker.com/t/cannot-connect-to-the-docker-daemon-is-the-docker-daemon-running-on-this-host/8925
Also I advice to try with a basic docker commands (simple build or run) before docker context with docker-compose configurations. For example, a lot of users notify the same error (Is the docker daemon running?) when one of these commands are executed:
docker info
docker run ...
docker ps
My gitlab-ci runs only after several attempts of retries. It returns the following error almost all the time -
Successfully installed PyYAML-3.13 awscli-1.16.133 botocore-1.12.123 colorama-0.3.9 docutils-0.14 futures-3.2.0 jmespath-0.9.4 pyasn1-0.4.5 python-dateutil-2.8.0 rsa-3.4.2 s3transfer-0.2.0 six-1.12.0 urllib3-1.24.1
You are using pip version 10.0.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ $(aws ecr get-login --no-include-email --region us-east-1)
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
error during connect: Post http://docker:2375/v1.39/auth: dial tcp: lookup docker on [ip here]:53: no such host
ERROR: Job failed: command terminated with exit code 1
Sometimes I ran into this error after I run the docker build command:
time="2019-03-28T18:20:24Z" level=error msg="failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial tcp: lookup docker on 10.19.240.10:53: no such host"
context canceled
However, after a couple of retries(a lot), the CI runs successfully and builds the docker image etc.
This is my yaml file(involving where it stops):
image: docker:stable
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
services:
- docker:dind
before_script:
- apk add --no-cache curl jq python py-pip sed git curl-dev bash git
- pip install awscli
stages:
- build
- deploy_staging
- deploy_production
I searched for some possible solutions but have not had luck yet.
Thanks
In case anyone gets this issue where your runners just keep failing all of a sudden,
simply clearing the cache in the pipeline menu will resolve this.
You need to be a maintainer of the project to be able to do this.
Remove below variable from Dockerfile
DOCKER_HOST: tcp://docker:2375/
and
Edit config.toml, default file location /etc/gitlab-runner/config.toml and modify the replace the below line on existing entry of volume
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
Another reason this could be happening is because the DinD container is not allowed to run in privileged (root) mode. This means it cannot start the docker-in-docker container causing docker commands to fail. More on this at https://docs.gitlab.com/runner/executors/docker.html#the-privileged-mode