Skip to main content
Version: 6.x (Latest)

Configure Terminal

DevSpace provides three modes for connecting your terminal to the dev container:

Mutual Exclusive

Beware that you can only enable one of the three modes since you only have one terminal locally.

However, if you open a second terminal locally, you could run on-demand commands such as devspace enter, devspace attach, or devspace logs which may achieve similar results but they will not do any implicit patches to your dev container.

Alternatively, the pipelines in your devspace.yaml could introduce custom flags such as --terminal or --attach to let the user pick which mode to enable.

Start New Terminal Session

Using the dev.*.terminal section in the devspace.yaml, you can tell DevSpace to start a terminal session inside the dev container and then connect to it as part of the start_dev process:

deployments:
app:
helm:
values:
containers:
- image: myregistry/myapp

dev:
my-dev:
imageSelector: myregistry/myapp
terminal: {}

Under the hood DevSpace will replace the running pod and apply the following changes, before actually starting a terminal to it:

  • Remove readinessProbes, startupProbes & livenessProbes
  • Change the entrypoint of the container to sleep 100000 only if dev.*.command and dev.*.args are not specified, otherwise it will respect these configs
POD REPLACE

If you do not want DevSpace to replace the pod with a modified version, use disableReplace: true

SCREEN

DevSpace will also try to install and use screen to start the terminal session, as this allows you to reconnect to your existing session after losing connection. You can disable this via the disableScreen: true option

Attach To Entrypoint

Attach can be used to attach to a process that is already running inside an existing container, typically the PID 1 process (container entrypoint).

Under the hood this mode is effectively calling kubectl attach.

deployments:
my-deployment:
helm:
values:
containers:
- image: ubuntu

dev:
my-dev:
imageSelector: ubuntu
attach: {}

Under the hood DevSpace will replace the running pod and apply the following changes, before actually attaching to it:

  • Remove readinessProbes, startupProbes & livenessProbes
  • Add stdin: true and tty: true to the container spec
info

If you don't want DevSpace to replace the pod with a modified version, use disableReplace: true

Stream Logs

Instead of starting an interactive terminal session or attaching to the container, you can also just stream the logs of the dev container.

The benefit of log streaming may be that you can stream the logs of multiple dev containers in parallel whereas a terminal connection can only be established to a single container at the time.

To configure log streaming, set the dev.*.logs field in the `devspace.yaml for the respective dev container:

dev:
my-dev-1:
imageSelector: ...
logs: {}
my-dev-2:
imageSelector: ...
logs: {}
my-dev-3:
imageSelector: ...
logs:
lastLines: 100

DevSpace will continously check what pods match the given selectors and start or end log streaming accordingly.

Config Reference

terminal required

Terminal allows you to tell DevSpace to open a terminal with screen support to this container

command required string

Command is the command that should be executed on terminal start. This command is executed within a shell.

workDir required string

WorkDir is the working directory that is used to execute the command in.

enabled required boolean false

If enabled is true, DevSpace will use the terminal. Can be also used to disable the terminal if set to false. DevSpace makes sure that within a pipeline only one dev configuration can open a terminal at a time and subsequent dev terminals will fail.

disableReplace required boolean false

DisableReplace tells DevSpace to not replace the pod or adjust its settings to make sure the pod is sleeping when opening a terminal

disableScreen required boolean false

DisableScreen will disable screen which is used by DevSpace by default to preserve sessions if connections interrupt or the session is lost.

disableTTY required boolean false

DisableTTY will disable a tty shell for terminal command execution

attach required

Attach allows you to tell DevSpace to attach to this container

enabled required boolean false

Enabled can be used to enable attaching to a container

disableReplace required boolean false

DisableReplace prevents DevSpace from actually replacing the pod with modifications so that the pod starts up correctly.

disableTTY required boolean false

DisableTTY is used to tell DevSpace to not use a TTY connection for attaching

logs required

Logs allows you to tell DevSpace to stream logs from this container to the console

enabled required boolean false

Enabled can be used to enable printing container logs

lastLines required integer

LastLines is the amount of lines to print of the running container initially