Skip to content

set the environment variables "password" for MySQL Docker image through the container configuration. #186

@Shuwen27

Description

@Shuwen27

Hallo. I am using the the official MySQL Docker image (command: docker pull mysql), which requires me to set the environment variables like "password" through the container configuration. I was wondering is there a way to set up the password in the function of create_project?

project = client.create_project(
repository=repository,
devcontainer=ImageDevContainer(
image=mysql,
),
)

Here is the code by using the package of docker to set up the password in the environment argument (environment={
"MYSQL_ROOT_PASSWORD": "password",},). See below.

import docker
client = docker.from_env()
container: containers.Container = client.containers.run(
image='mysql',
name=f"mysql_{port}",
environment={
"MYSQL_ROOT_PASSWORD": "password",
},
ports={"3306":port},
detach=True,
tty=True,
stdin_open=True,
remove=True,
)

Thank you for your help!!!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions