简体   繁体   English

从 dockerfile 构建 docker 镜像

[英]building docker image from dockerfile

Here is my command in terminal to build image, sudo docker build -t actinbox3.2:latest .这是我在终端中构建映像的sudo docker build -t actinbox3.2:latest

I'm getting this error我收到这个错误

" 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/

Mydockerfile in Base基地中的 Mydockerfile

Dockerfile for base image of actInbox 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

Please help me out or any idea why im getting this error?请帮助我或知道为什么我会收到此错误? I have an account in docker hub...........我在 docker hub 有一个账号…………

Thank you in advance!先感谢您!

Basically, it can't find the iamdenmarkcontrevida/base image in dockerhub.基本上,它在iamdenmarkcontrevida/base找不到iamdenmarkcontrevida/base映像。

Did you build/push the base image?您是否构建/推送了基本映像?

docker build .
docker tag <local-image-id> iamdenmarkcontrevida/base:latest
docker push iamdenmarkcontrevida/base

No need push, if you only need run it locally.不需要推送,如果你只需要在本地运行它。

So you need build the base image first, then build actinbox3.2所以需要先构建基础镜像,然后再构建actinbox3.2

For example (suppose you have different Dockerfile name)例如(假设您有不同的 Dockerfile 名称)

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

tag latest is default, so no need add it in build command.标签latest是默认的,所以不需要在构建命令中添加它。

You can try packer framework你可以试试打包框架
that is easiest way to create docker image.这是创建 docker 镜像的最简单方法。 it also supported many other type of machine image.它还支持许多其他类型的机器映像。

https://www.packer.io/docs/builders/index.html https://www.packer.io/docs/builders/index.html

It's just a two line command -这只是一个两行命令 -

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

For me docker build -t condescending_greider/newdoc:latest .对我来说docker build -t condescending_greider/newdoc:latest .

Thanks for your time :)谢谢你的时间 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM