Build a new image
There are three ways you can build new images.
On a multi-node environment, the built image will only be available on the node you select in the Deployment section. To make the image available to all nodes, consider adding a registry to Portainer.
When building an image with Portainer, you are unable to use ADD
or COPY
commands referencing files on the host. We recommend using wget
or similar to retrieve files from a HTTP/S URL instead.
Method 1: Using the Portainer web editor
From the menu select Images then click Build a new image.
![](https://docs.portainer.io/~gitbook/image?url=https%3A%2F%2F3752558522-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FiZWHJxqQsgWYd9sI88sO%252Fuploads%252FtARqMBEcz3SNybweouzL%252F2.15-docker_images_build_image.gif%3Falt%3Dmedia%26token%3D9b518ded-2286-4748-ba6a-d4193ddc44e9&width=768&dpr=4&quality=100&sign=29424605&sv=1)
Next, give the image a descriptive name (you can enter multiple names), select the Web editor option under Build method, then write your Dockerfile in the web editor.
You can search within the web editor at any time by pressing Ctrl-F
(or Cmd-F
on Mac).
![](https://docs.portainer.io/~gitbook/image?url=https%3A%2F%2F3752558522-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FiZWHJxqQsgWYd9sI88sO%252Fuploads%252FVMKsnUZQCArSbqdl7A3t%252F2.15-docker_images_build_web_editor.png%3Falt%3Dmedia%26token%3D184e831e-30d9-42cf-8910-29f06bb02c36&width=768&dpr=4&quality=100&sign=a0d01b1d&sv=1)
Optionally, you can upload one or more local files to be included in an image by clicking Select files and selecting the files to include. You can then reference them in your Dockerfile.
![](https://docs.portainer.io/~gitbook/image?url=https%3A%2F%2F3752558522-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FiZWHJxqQsgWYd9sI88sO%252Fuploads%252FMcY00MsQIxk4Ai6DCRN1%252F2.16-images-build-upload.png%3Falt%3Dmedia%26token%3D8212bfcc-1688-49bb-bd3f-9d6343a865eb&width=768&dpr=4&quality=100&sign=2f0e5391&sv=1)
Select the node you want to save the image on (if on a multi-node environment) then click Build the image.
![](https://docs.portainer.io/~gitbook/image?url=https%3A%2F%2F3752558522-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FiZWHJxqQsgWYd9sI88sO%252Fuploads%252FC3f9Yp3wmSgDh46ZAE8a%252F2.15-docker_images_build_deployment.png%3Falt%3Dmedia%26token%3D9d1bce21-dcd4-43b5-bfc9-6e52d332520f&width=768&dpr=4&quality=100&sign=54bdbf38&sv=1)
When the build is finished, select the Output tab to view the build history and the result.
Method 2: Uploading a Dockerfile
If you have an existing Dockerfile, you can upload it to Portainer and use it to build the image.
From the menu select Images then click Build a new image.
![](https://docs.portainer.io/~gitbook/image?url=https%3A%2F%2F3752558522-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FiZWHJxqQsgWYd9sI88sO%252Fuploads%252FAbGyrMMvMAQKIJAqsfgH%252F2.15-docker_images_build_image_upload.gif%3Falt%3Dmedia%26token%3De5a7465d-796b-4786-8fb9-07db67214b2d&width=768&dpr=4&quality=100&sign=1a852f0&sv=1)
Next, give the image a descriptive name (you can enter multiple names), select the Upload option under Build method, then browse to and upload the Dockerfile.
![](https://docs.portainer.io/~gitbook/image?url=https%3A%2F%2F3752558522-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FiZWHJxqQsgWYd9sI88sO%252Fuploads%252FmlIUs1EBDKaRueT3rJRy%252F2.15-docker_images_build_upload.png%3Falt%3Dmedia%26token%3Db43be914-fd8c-4655-944e-5e106e775638&width=768&dpr=4&quality=100&sign=382e16f4&sv=1)
Scroll down and select the node you want to save the image on (if on a multi-node environment) then click Build the image.
![](https://docs.portainer.io/~gitbook/image?url=https%3A%2F%2F3752558522-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FiZWHJxqQsgWYd9sI88sO%252Fuploads%252FC3f9Yp3wmSgDh46ZAE8a%252F2.15-docker_images_build_deployment.png%3Falt%3Dmedia%26token%3D9d1bce21-dcd4-43b5-bfc9-6e52d332520f&width=768&dpr=4&quality=100&sign=54bdbf38&sv=1)
When the build is finished, select the Output tab to view the build history and the result.
Method 3: Providing a Dockerfile from a URL
If the Dockerfile is hosted on the Internet (either in a tarball or a public GitHub repository), you can download it directly to Portainer via its URL.
From the menu select Images then click Build a new image.
![](https://docs.portainer.io/~gitbook/image?url=https%3A%2F%2F3752558522-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FiZWHJxqQsgWYd9sI88sO%252Fuploads%252FwxQw9k9gAeRuWH2w20v7%252F2.15-docker_images_build_image_URL.gif%3Falt%3Dmedia%26token%3Dcfa2197e-7303-4ae6-88ff-7215567214fc&width=768&dpr=4&quality=100&sign=ae151c63&sv=1)
Next, give the image a descriptive name (you can enter multiple names), select the Upload option under Build method, then enter the URL of the file and the Dockerfile path within the tarball or repository.
![](https://docs.portainer.io/~gitbook/image?url=https%3A%2F%2F3752558522-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FiZWHJxqQsgWYd9sI88sO%252Fuploads%252Fg0Bo6W8HzDIiZbAKJJFK%252F2.15-docker_images_build_URL.png%3Falt%3Dmedia%26token%3Dcebf7bfa-ce8b-44f8-9ff2-05b2b227ae1a&width=768&dpr=4&quality=100&sign=7b96fca6&sv=1)
Scroll down and select the node you want to save the image on (if on a multi-node environment) click Build the image.
![](https://docs.portainer.io/~gitbook/image?url=https%3A%2F%2F3752558522-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FiZWHJxqQsgWYd9sI88sO%252Fuploads%252FC3f9Yp3wmSgDh46ZAE8a%252F2.15-docker_images_build_deployment.png%3Falt%3Dmedia%26token%3D9d1bce21-dcd4-43b5-bfc9-6e52d332520f&width=768&dpr=4&quality=100&sign=54bdbf38&sv=1)
When the build is finished, select the Output tab to view the build history and the result.
Last updated