Vinay
Vinay

Reputation: 725

How to create a Image from a Docker Container?

As I want to make my existing application as a Docker images. And I have to install lot of installation which I can't do using Docker file. How I am doing is I created a Docker container with OS, and log-in in to that and I Installed all the software I needed. Now I want to make the image out of it.

Upvotes: 3

Views: 2369

Answers (2)

Tryph
Tryph

Reputation: 6209

docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

See the doc for more detailed explanation


Unless you have very specific need which prevents using Dockerfile to build your image, you should prefer the Dockerfile with the docker build command

Upvotes: 0

Victor Wong
Victor Wong

Reputation: 3761

You can use docker commit.

Check out Docker commit official documentation:

docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

--author , -a Author (e.g., “John Hannibal Smith [email protected]”)

--change , -c Apply Dockerfile instruction to the created image

--message , -m Commit message

--pause , -p true Pause container during commit

Note this important remark:

By default, the container being committed and its processes will be paused while the image is committed. This reduces the likelihood of encountering data corruption during the process of creating the commit.

However this is not the best practice. You should build everything using a dockerfile for maintainability.

Upvotes: 3

Related Questions