code

apt-add-repository : Dockerfile에서 명령을 찾을 수 없음 오류

codestyles 2020. 12. 8. 08:05
반응형

apt-add-repository : Dockerfile에서 명령을 찾을 수 없음 오류


터미널에서 매우 간단한 Docker 파일을 만들었습니다. 기본적으로 다음을 수행했습니다.

mkdir pgrouted
cd pgrouted
touch Dockerfile

이제 nano 편집기 에서 Docker 파일을 열고 Docker 파일에 다음 명령을 추가합니다.

FROM ubuntu

MAINTAINER Gautam <gautamx07@yahoo.com>

LABEL Description="pgrouting excercise" Vendor="skanatek" Version="1.0"

ENV BBOX="-122.8,45.4,-122.5,45.6"

# Add pgRouting launchpad repository
RUN sudo apt-add-repository -y ppa:ubuntugis/ppa
RUN sudo apt-add-repository -y ppa:georepublic/pgrouting
RUN sudo apt-get update

# Install pgRouting package (for Ubuntu 14.04)
RUN sudo apt-get install postgresql-9.3-pgrouting

# Install osm2pgrouting package
RUN sudo apt-get install osm2pgrouting

# Install workshop material (optional, but maybe slightly outdated)
RUN sudo apt-get install pgrouting-workshop

# For workshops at conferences and events:
# Download and install from http://trac.osgeo.org/osgeo/wiki/Live_GIS_Workshop_Install
RUN wget --no-check-certificate https://launchpad.net/~georepublic/+archive/pgrouting/+files/pgrouting-workshop_2.0.6-ppa1_all.deb

RUN sudo dpkg -i pgrouting-workshop_2.0.6-ppa1_all.deb

# Review: Not sure weather this should be in the dockerfile
RUN cp -R /usr/share/pgrouting/workshop ~/Desktop/pgrouting-workshop

# Log in as user "user"
RUN psql -U postgres

# Create routing database
RUN CREATE DATABASE routing;

# Add PostGIS functions
RUN CREATE EXTENSION postgis;

# Add pgRouting core functions
CREATE EXTENSION pgrouting;

# Download using Overpass XAPI (larger extracts possible than with default OSM API)
wget --progress=dot:mega -O "sampledata.osm" "http://www.overpass-api.de/api/xapi?*[bbox=${BBOX}][@meta]"

전체 Dockerfile은 여기 에서 한 눈에 볼 수 있습니다 .

이제 Dockerfile을 빌드하려고하면 다음과 같이됩니다.

docker build -t gautam/pgrouted:v1 .

Dockerfile이 실행되고 다음 오류가 발생합니다.

Step 4 : RUN sudo apt-add-repository -y ppa:ubuntugis/ppa
 ---> Running in c93c3c5fd5e8
sudo: apt-add-repository: command not found
The command '/bin/sh -c sudo apt-add-repository -y ppa:ubuntugis/ppa' returned a non-zero code: 1

이 오류가 발생하는 이유는 무엇입니까?


apt-add-repository 는 기본 Ubuntu 이미지에 없습니다. 먼저 설치해야합니다. 시험apt-get install software-properties-common

그런데 명령을 사용하여 다른 사용자로 변경하지 않는 한 기본적으로 명령이 루트로 실행되기 때문에 Dockerfile에서 sudo 를 사용할 필요가 없습니다 USER.


Add these lines before running apt-add-repository command

RUN apt-get update
RUN apt-get install -y software-properties-common

참고URL : https://stackoverflow.com/questions/32486779/apt-add-repository-command-not-found-error-in-dockerfile

반응형