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.
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.