从Dockerfile构建Docker镜像

7

这里是在终端中构建镜像的命令,sudo docker build -t actinbox3.2:latest .

我遇到了以下错误:

" Step 0 : FROM iamdenmarkcontrevida/base
        Pulling repository iamdenmarkcontrevida/base
        INFO[0020] Repository not found"

Dockerfile

    # Dockerfile for base image of actInbox
    FROM iamdenmarkcontrevida/base

    MAINTAINER Denmark Contrevida<DMcontrevida@gmail.com>


    # Config files
    COPY config /actinbox_config/
    COPY script /actinbox_script/
    COPY database /actinbox_db/

    # Config pyenv
    RUN echo 'export PYENV_ROOT="/root/.pyenv"' >> /root/.bashrc && \
        echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> /root/.bashrc && \
        echo 'eval "$(pyenv init -)"' >> /root/.bashrc && \
    # Config Nginx
        rm /etc/nginx/sites-enabled/default && \
        ln -s /actinbox_config/actinbox.conf /etc/nginx/sites-enabled/actinbox.conf && \
    # Config PostgreSQL
        rm /etc/postgresql/9.3/main/pg_hba.conf && \
        ln -s /actinbox_config/pg_hba.conf /etc/postgresql/9.3/main/pg_hba.conf && \
    # Create DB & Restore database
        sh /actinbox_config/create_db_actinbox.sh && \
    # Delete template folder
        rm -r /actinbox_db/

我的dockerfile基础镜像

actInbox基础镜像的Dockerfile

    FROM ubuntu:14.04

    MAINTAINER Denmark Contrevida<DMcontrevida@gmail.com> 

    # Base services
    RUN apt-get update && apt-get install -y \
        git nginx postgresql postgresql-contrib

    # Install Pyenv, Python 3.x, django, uWSGI & psycopg2
    COPY config/install_pyenv.sh /tmp/install_pyenv.sh
    RUN sh /tmp/install_pyenv.sh

请帮我看看,或者有什么想法,为什么我会得到这个错误? 我在Docker Hub上有一个帐户...........

提前谢谢!

5个回答

5
基本上,dockerhub中找不到iamdenmarkcontrevida/base镜像。
您是否构建/推送了基础镜像?
docker build .
docker tag <local-image-id> iamdenmarkcontrevida/base:latest
docker push iamdenmarkcontrevida/base

如果我从零开始怎么办?比如说我想要更新所有镜像上的软件。 - Den Contre

1

如果您只需要在本地运行,无需推送。

因此,您需要首先构建基础映像,然后构建actinbox3.2

例如(假设您有不同的Dockerfile名称)

sudo docker build -t iamdenmarkcontrevida/base -f Dockerfile.base
sudo docker build -t actinbox3.2 -f Docker.actinbox3.2

标签latest是默认值,因此在构建命令中不需要添加它。


1
在目录中包含DockerFile,打开命令提示符,然后输入以下命令: docker build -f Dockerfile ..
它会生成一个ID,并在下一个命令中使用: docker tag ID imagename

enter image description here


1

这只是一个两行命令 -

  1. 获取您的本地镜像 ID
docker ps
  1. 复制名称
docker build -t local-image-id/Any name you want:latest . 

对我来说

docker build -t condescending_greider/newdoc:latest .

感谢您的时间 :)


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接