Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
239 views
in Technique[技术] by (71.8m points)

Packer Docker builder with nginx as base image

Expecting

Here is my packer file:

{
        "builders" : [
        {
                "type": "docker",
                "image": "nginx",
                "commit": "true"
        }
        ],
        "provisioners" : [
        {
                "type": "file",
                "source": "./index.html",
                "destination": "/usr/share/nginx/html/index.html"
        }
        ],
        "post-processors" : [
        {
                "type": "docker-tag",
                "repository": "repo",
                "tag": "latest"
        }
        ]
}

After packer build for above file when running the docker container out of the above outputted artifact i.e. custom nginx docker image with command docker run -it -d -p 8080:80 --name web repo, observed that the docker container comes up, port is occupied but nginx process isn't running inside the docker container due to which html content is not accessible on the specified port. URL: http://localhost:8080

However, the above scenario of creating custom nginx docker image and running docker container for the same is performed using below Dockerfile with docker commands it works fine i.e. docker container comes up, port is occupied and also HTML content is accessible:

Here is the Dockerfile:

FROM nginx:latest
COPY ./index.html /usr/share/nginx/html/index.html

I need to use packer docker builder, what can be the possible problem? Are there any limitations on usage of docker builder with packer or with nginx?

question from:https://stackoverflow.com/questions/66064621/packer-docker-builder-with-nginx-as-base-image

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...