Skip to content

Ability to add new extrahost (new line into /etc/hosts file) to already created container #1906

Closed Answered by mdelapenya
igribkov asked this question in Q&A
Discussion options

You must be logged in to vote

@igribkov ah ok, I'm sorry, I thought your question was about container creation instead of "after it's been created and its running", right?

You can leverage the PostStarts container lifecycle hook, to inject a function that appends the entries you are interested. Please check the logs for the lifecycle hooks here, and an example here:

func TestWithStartupCommand(t *testing.T) {
req := testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{
Image: "alpine",
Entrypoint: []string{"tail", "-f", "/dev/null"},
},
Started: true,
}
testExec := t…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@igribkov
Comment options

@mdelapenya
Comment options

Answer selected by mdelapenya
@igribkov
Comment options

@mdelapenya
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants