Direkt zum Inhalt

ERROR [2/6] RUN apt-get update -y

0

I am trying to create a docker image and upload the image to Amazon ECR using a docker-image.sh script from Core Systems Modernization Labs. Every time I run it fails and finished at the same step. Here below is the shell script:

#!/bin/bash

This script creates a docker image of the apps and uploads the image to Amazon ECR.

source ~/.bash_profile

echo "Creating an ECR image for the deposit application"

cd /home/ec2-user/environment/deposit-app

Create an ECR image for the deposit application

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com docker build -t deposit-app-$ACCOUNT_ID . docker tag deposit-app-$ACCOUNT_ID:latest $ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/deposit-app-$ACCOUNT_ID:latest docker push $ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/deposit-app-$ACCOUNT_ID:latest

echo "Creating an ECR image for the mortgage application"

cd /home/ec2-user/environment/mortgage-app

Create an ECR image for the mortgage application

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com docker build -t mortgage-app-$ACCOUNT_ID . docker tag mortgage-app-$ACCOUNT_ID:latest $ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/mortgage-app-$ACCOUNT_ID:latest docker push $ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/mortgage-app-$ACCOUNT_ID:latest

gefragt vor 2 Monaten40 Aufrufe
2 Antworten
0

The error you're encountering at the "RUN apt-get update -y" step in your Docker build process could be due to several reasons:

  1. Network connectivity issues: The Docker build process might not be able to reach the package repositories. This could be due to network restrictions, proxy settings, or DNS resolution problems.

  2. Repository server issues: The Ubuntu/Debian package repositories might be temporarily unavailable or experiencing issues.

  3. Docker daemon configuration: There might be issues with how your Docker daemon is configured, particularly related to networking.

To resolve this issue, you can try the following solutions:

  1. Check your network connectivity and ensure that your environment can access external repositories.

  2. Add DNS configuration to your Dockerfile before the apt-get command:

RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf
RUN apt-get update -y
  1. Try using a different base image or specify a specific version of your current base image.

  2. If you're behind a proxy, make sure to configure Docker to use it:

# In your Dockerfile
ENV http_proxy=http://proxy.example.com:port
ENV https_proxy=http://proxy.example.com:port
  1. Verify that your AWS ECR repositories exist and that you have the necessary permissions to push to them. You can check this by running:
aws ecr describe-repositories --region us-east-1
  1. Ensure that the ACCOUNT_ID environment variable is correctly set in your ~/.bash_profile file.

After making these changes, try running your script again to see if the Docker build process completes successfully.
Sources
Amazon ECS stopped task error messages updates - Amazon Elastic Container Service
Step 3: Create the application image and upload the Docker file to your Amazon ECR repository - Amazon Keyspaces (for Apache Cassandra)

beantwortet vor 2 Monaten
EXPERTE
überprüft vor 2 Monaten
0
  1. Can you run the bash script in verbose mode and share the output?

$ bash -x docker-image.sh

  1. Can you share the Dockerfile content?
  2. You don't need to login to same ecr repo twice
beantwortet vor 2 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.