containerFromBuild starts a container from a local image build. - imageTag specifies the name the built image should be tagged as. - files specifies the list of local files to send as part of the build context. - cmd specifies the command line in execv format if any. - env specifies the environment
( t *testing.T, imageTag string, files map[string][]byte, cmd []string, env []string, ports map[string]string, )
| 38 | // - ports specifies the port mappings. The key is the container port, the value is the host port. |
| 39 | // If the host port is left empty it is automatically mapped and can be retrieved later. |
| 40 | func containerFromBuild( |
| 41 | t *testing.T, |
| 42 | imageTag string, |
| 43 | files map[string][]byte, |
| 44 | cmd []string, |
| 45 | env []string, |
| 46 | ports map[string]string, |
| 47 | ) container { |
| 48 | t.Helper() |
| 49 | t.Logf("Creating and starting a container from local build...") |
| 50 | |
| 51 | cnt := &dockerContainer{ |
| 52 | client: dockerClient(t), |
| 53 | files: files, |
| 54 | image: imageTag, |
| 55 | t: t, |
| 56 | cmd: cmd, |
| 57 | env: env, |
| 58 | ports: ports, |
| 59 | } |
| 60 | |
| 61 | cnt.build() |
| 62 | cnt.create() |
| 63 | t.Cleanup(cnt.remove) |
| 64 | cnt.start() |
| 65 | cnt.inspect() |
| 66 | |
| 67 | return cnt |
| 68 | } |
| 69 | |
| 70 | // containerFromBuild starts a container from an image pulled from a registry |
| 71 | // |