docker - apt-add-repository : command not found error in Dockerfile

标签 docker

我刚刚在我的终端中做了一个非常简单的 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可以看 HERE 一目了然。

现在当我尝试构建 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,因为这些命令默认以 root 身份运行,除非您使用 USER 命令更改为另一个用户.

关于docker - apt-add-repository : command not found error in Dockerfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32486779/

相关文章:

windows - Windows 的 Docker ip

templates - 撰写文件Docker中的模板语法

docker - 谷歌云上基于 Windows 的容器运行

docker - 容器命令 '/start.sh' 未找到或不存在,容器的入口点是 shell 脚本

docker - 具有不同API URL的Dockerized Vue SPA,具体取决于运行位置

docker - 如何将新软件包安装到非 root Docker 容器中?

docker - Web UI 代码和微服务在同一个 monorepo 中?

postgresql - Docker exec - 无法使用环境变量调用 postgres

python - 从 python 脚本运行 shell 命令\n

python - 将 Django 与 Docker 一起使用时出错 - "Can' t 连接到 '127.0.0.1' (111) 上的 MySQL 服务器"