-
Notifications
You must be signed in to change notification settings - Fork 881
Do not disconnect from coder_app after command #7931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You could do this with |
Any success @jaulz. Please update if you were able to make it work. |
@kylecarbs thanks a lot for the tip, that worked great! 😊 The only minor issue is that it still displays this warning which can be misleading: |
And while we are here, I have another use case where I just want to print the content of a file:
The |
you could give https://filebrowser.org/ a try by creating a |
@matifali perfect, that works as well. Thanks! 😊 So it's now just about the screenshot that I posted above... |
@mafredri and @BrunoQuaresma is this an expected behaviour? |
Yes, this warning will be displayed until the startup script is done. |
Actually, I think the startup script should finish because I use the init script of the agent in the container. It has a custom startup script but that uses resource "docker_network" "internal" {
name = "${data.coder_parameter.namespace.value}"
}
resource "coder_agent" "postgres" {
arch = data.coder_provisioner.me.arch
os = "linux"
startup_script = <<EOT
#!/bin/bash
cd /
exec /usr/local/bin/entrypoint.sh postgres &
EOT
}
resource "docker_container" "postgres" {
count = data.coder_workspace.me.start_count
image = docker_image.postgres.image_id
# Uses lower() to avoid Docker restriction on container names.
name = "${data.coder_parameter.namespace.value}-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}-postgres"
hostname = "postgres"
dns = ["1.1.1.1"]
# Use the docker gateway if the access URL is 127.0.0.1
entrypoint = ["sh", "-c", replace(coder_agent.postgres.init_script, "127.0.0.1", "host.docker.internal")]
command = ["postgres"]
env = [
"CODER_AGENT_TOKEN=${coder_agent.postgres.token}",
"POSTGRES_PASSWORD=${var.postgres_password}"
]
host {
host = "host.docker.internal"
ip = "host-gateway"
}
volumes {
container_path = "/var/lib/postgresql/data"
volume_name = docker_volume.postgres_data.name
read_only = false
}
networks_advanced {
name = docker_network.internal.name
}
restart = "unless-stopped"
} |
Maybe the process is still open. This warning is only displayed when the startup script is running. Just checking with @mafredri |
@jaulz It's possible it won't exit even though it seems like it should, see about redirecting stdout and stderr here: https://coder.com/docs/v2/latest/templates#startup_script |
It would be great if the coder apps do not disconnect automatically after they return. To ensure compatibility it would of course be fine to have a parameter (e.g.
tty=true
?) to control it. My use case is that I want to list the log files in the database via:Unfortunately, once opened it immediately says "Disconnected" and I cannot even view the result but actually I would like to use it as a starting point to run further commands.
The text was updated successfully, but these errors were encountered: