apt添加存储库:Dockerfile中出现命令未找到错误

u1ehiz5o  于 2022-11-22  发布在  Docker
关注(0)|答案(3)|浏览(175)

我只是做了一个非常简单的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

为什么会出现此错误?

ltskdhd1

ltskdhd11#

apt-add-repository不在基本Ubuntu镜像中。您首先需要安装它。请尝试apt-get install software-properties-common
顺便说一下,您不需要在Dockerfile中使用sudo,因为默认情况下,这些命令以root用户身份运行,除非您使用USER命令更改为另一个用户。

368yc8dk

368yc8dk2#

在运行apt-add-repository命令之前添加这些行

RUN apt-get update && \
    apt-get install -y software-properties-common && \
    rm -rf /var/lib/apt/lists/*
8yoxcaq7

8yoxcaq73#

RUN apt-get update --fix-missing && \
apt-get install -y software-properties-common && \
rm -rf /var/lib/apt/lists/*  && \
add-apt-repository ppa:ondrej/php && \
apt install -y nginx php7.4-fpm php7.4-mysql php7.4-curl net-tools telnet php7.4-gd php-mail php7.4 php7.4-common php7.4-sqlite3 php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-mysql php7.4-gd php7.4-xml php7.4-cli php7.4-zip php7.4-soap unzip  && \
rm -rf /var/lib/apt/lists/* && \
apt clean

相关问题