Illusionist
Illusionist

Reputation: 5489

Using docker pull & run to build dockerfile

I'm learning how to use docker.

I want to deploy a microservice for swagger. I can do

docker pull schickling/swagger-ui
docker run -p 80:8080 -e API_URL=http://myapiurl/api.json swaggerapi/swagger-ui

To deploy it, I need a dockerfile i can run. How do i generate the dockerfile in a way I can run it with docker build ?

Upvotes: 0

Views: 1747

Answers (2)

Spangen
Spangen

Reputation: 4730

The original question asks for a Dockerfile, perhaps for some CI/CD workflow, so this answer addresses that requirement:

Create a very simple Dockerfile beginning with

FROM schickling/swagger-ui

Then from that directory run

$ docker build -t mycontainername .

Which can then be run:

$ docker run -p 80:8080 -e API_URL=http://myapiurl/api.json mycontainername

Upvotes: 1

Coy
Coy

Reputation: 573

Usually the docker pull pulls the Dockerfile. The Dockerfile for swagger is on the docker repo for it if you wanted to edit it or customize it. (https://hub.docker.com/r/schickling/swagger-ui/~/dockerfile/)

That one should work with the build command. The build command builds the image, the run command turns the image into a container. The docker pull command should pull the image in. You don't need to run docker build for it as you should already have the image from the pull. You only need to do docker run.

Upvotes: 1

Related Questions