我只是想建立我Dockerfile,看下面:如何運行並登錄到容器進行調試?
FROM ubuntu:14.04
MAINTAINER Mike Dillon <[email protected]>
ENV POSTGIS_MAJOR 2.1
ENV POSTGIS_VERSION 2.1.7+dfsg-3~94.git954a8d0.pgdg80+1
# temporary instruction, i beleive all the apt-get etc commands will need to be RUN in the
# RUN -t -i ubuntu:14.04 /bin/bash
RUN apt-get install postgresql-client
RUN apt-get update && apt-get install -y --no-install-recommends postgresql-$PG_MAJOR-po$
postgis=$POSTGIS_VERSION && rm -rf /var/lib/apt/lists/*
RUN mkdir -p /docker-entrypoint-initdb.d
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/postgis.sh
現在的幾行代碼的運行,比我得到以下錯誤:
Need to get 2538 kB of archives.
After this operation, 12.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
The command '/bin/sh -c apt-get install postgresql-client' returned a non-zero code: 1
現在我不關心Dockerfile和錯誤,事實上我知道錯誤是什麼,我沒有將-y
標誌添加到RUN apt-get install postgresql-client
命令中。我的問題是有關調試的,我的同事給了我下面的建議遵循每次我得到一個錯誤,當我試圖建立一個Dockerfile:
The non-zero code means that there was an error running this task. To test exactly what's wrong, you can run and login the container, and run this command manually inside the container.
現在,我怎麼run and login the container
?我不太瞭解那部分,有人可以解釋嗎?
這有助於調試嗎?我仍然不明白,對不起問題! –
這取決於。在這種情況下,當您手動運行該命令並且看到錯誤時,可以使用'-y'選項再次運行以證明問題可以得到解決。在其他情況下,例如在shell腳本中啓用調試選項,使用'-x'選項運行等。如果這有幫助,您還可以通過日誌文件。 – BMW