apt-add-repository:在Dockerfile中找不到命令错误 [英] apt-add-repository: command not found error in Dockerfile

查看:109
本文介绍了apt-add-repository:在Dockerfile中找不到命令错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在终端中制作了一个非常简单的Docker文件,基本上我做了以下事情:

I just made a very simple Docker file in my terminal, basically I did the following:

mkdir pgrouted
cd pgrouted
touch Dockerfile

现在我在 nano 编辑器,然后将以下命令添加到Docker文件:

Now I open the Docker file in the nano editor, and I add the following commands to the Docker file:

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可以一目了然 HERE

The entire Dockerfile can be see HERE at a glance.

现在,当我尝试构建Dockerfile时,就像这样:

Now when I try to build the Dockerfile, like so:

docker build -t gautam/pgrouted:v1 .

Dockerfile运行,然后出现以下错误:

The Dockerfile runs and then I get the below error:

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

apt-add-repository is just not in the base Ubuntu image. You'll first need to install it. try apt-get install software-properties-common

顺便说一句,您不需要使用< Dockerfile中的em> sudo ,因为默认情况下命令以root身份运行,除非您使用 USER 命令更改为另一个用户。

By the way, you don't need to use sudo in the Dockerfile because the commands run as root by default unless you change to another user with the USER command.

这篇关于apt-add-repository:在Dockerfile中找不到命令错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆