2015-09-09 20 views
15

Tôi chỉ cần thực hiện một tập tin Docker rất đơn giản trong thiết bị đầu cuối của tôi, về cơ bản tôi đã điều sau đây:apt-add-kho: command not found lỗi trong Dockerfile

mkdir pgrouted 
cd pgrouted 
touch Dockerfile 

Bây giờ tôi mở file Docker trong trình soạn thảo nano và tôi thêm các lệnh sau vào file Docker:

FROM ubuntu 

MAINTAINER Gautam <[email protected]> 

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 

# login 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]" 

toàn bộ Dockerfile có thể được nhìn thấy HERE trong nháy mắt.

Bây giờ khi tôi cố gắng xây dựng các dockerfile, như vậy:

docker build -t gautam/pgrouted:v1 . 

Các dockerfile chạy và hơn tôi nhận được lỗi sau:

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 

Ai đó có thể cho tôi biết tại sao tôi lại nhận được này lỗi ?

Trả lời

19

apt-add-repository không có trong hình ảnh cơ bản của Ubuntu. Trước tiên, bạn cần phải cài đặt nó. thử apt-get install software-properties-common

Bằng cách này, bạn không cần phải sử dụng sudo trong Dockerfile vì các lệnh chạy bằng root theo mặc định trừ khi bạn thay đổi để người dùng khác với lệnh USER.

+1

tôi đã thêm 'pt-get install software-properties-common' làm lệnh' RUN pt-get install-properties-common' đầu tiên, như vậy, bây giờ tôi gặp lỗi này http://chopapp.com/ # 8a4vdsnw –

+1

tùy thuộc vào phiên bản Ubuntu của bạn, nó có thể là 'python-software-properties' hoặc' software-properties-common' – user2915097

+1

trên ubuntu 16.04 điều này muốn cài đặt thêm 46MiB dữ liệu:/quá nhiều để có thể thực thi một cách đơn giản chỉ huy. – cweiske