-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow passing options to
Docker::Image.create
The [Docker ImageCreate](https://docs.docker.com/engine/api/v1.43/#tag/Image/operation/ImageCreate) api accepts a variety of parameters. For the `platform` behavior, there is default behavior which is notable: ``` Default: "" When used in combination with the fromImage option, the daemon checks if the given image is present in the local image cache with the given OS and Architecture, and otherwise attempts to pull the image. If the option is not set, the host's native OS and Architecture are used. ... ``` Because it defauilts to the host's native architecture, it will attempt to pull images matching that architecture and raises not found if an image of that architecture doesn't exist. This can be a problem when, for example, attempting to pull a `mysql` image on Mx Macs. `Testcontainers::DockerContainer.create('mysql:5.7')` will fail because, as of this writing, arm images are not created for `mysql:5.7`. The solution to this is to pass `platform: 'linux/amd64'` to `Docker::Image.create`. This tells Docker we specifically want a image for that architecture (Rosetta on Mac OS X can run `linux/amd64` images). This commit adds an optional `image_create_options` kwarg to `DockerContainer#initialize` that defaults to an empty hash. This kwarg allows for us to pass create parameters to `Docker::Image.create`. I've also added a `NotFoundError` class because it seems that the convention is to wrap dependency errors in a `Textcontainers` error class. Updates the readme, including a readme addition to explain the changes in #31.
- Loading branch information
1 parent
ee68f9f
commit 9f09d43
Showing
4 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters