0

I'm trying to add new gems to an existing Docker image which doesn't have a Dockerfile. Below is what I have tried:

 - logged into the `bash` Docker image 
 - gem install <new dependency>

How do I create a new image after the above steps?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
shiv455
  • 7,384
  • 19
  • 54
  • 93

1 Answers1

2

Use the docker commit command. See here.

brianolive
  • 1,573
  • 2
  • 9
  • 19
  • Thanks this worked for me `docker commit --change='CMD [gem install aws-sdk]' 1jsrgi7748 myimage:v2` – shiv455 Jun 28 '18 at 02:25
  • The `—change` parameter expects Dockerfile commands. “gem” is not a Dockerfile command. See [here](https://docs.docker.com/engine/reference/commandline/commit/#options), under Extended Description. For what you are wanting to do, you need to run the “gem” command ni a running container. `sudo docker exec -it [container name] bash` - that will give you an interactive bash session. From there you can run your Ruby command. – brianolive Jun 28 '18 at 02:28