Allow passing options to Docker::Image.create
#33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Docker ImageCreate api accepts a variety of parameters, you can pass those arguments in a hash as the first argument to
Docker:Image.create
For the
platform
behavior, there is default behavior which is notable: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 formysql:5.7
.The solution to this is to pass
platform: 'linux/amd64'
toDocker::Image.create
. This tells Docker we specifically want a image for that architecture (Rosetta on Mac OS X can runlinux/amd64
images).This commit adds an optional
image_create_options
kwarg toDockerContainer#initialize
that defaults to an empty hash. This kwarg allows for us to pass create parameters toDocker::Image.create
.I've also added a
NotFoundError
class because it seems that the convention is to wrap dependency errors in aTextcontainers
error class.Updates the readme, including a readme addition to explain the changes in #31.