cli icon indicating copy to clipboard operation
cli copied to clipboard

Environment variables from legacy containers links have disappeared with docker 29.0

Open thomas-riccardi opened this issue 3 months ago • 3 comments

Description

Environment variables created by docker when using legacy containers links disappeared with docker 29.0: https://docs.docker.com/engine/network/links/#environment-variables

Reproduce

  1. docker run --rm --name container1 -p 1234 -d ubuntu sleep infinity > /dev/null
  2. docker run --rm --name container2 --link container1 ubuntu env

cleanup:

  • docker stop container1 --timeout 0 > /dev/null

Expected behavior

CONTAINER1_PORT should exist in step 2, as well as other CONTAINER1_* environment variables:

docker 28.5.1: (5:28.5.2-1~ubuntu.22.04~jammy)

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=aa0dd55feb85
CONTAINER1_PORT=tcp://172.17.0.2:1234
CONTAINER1_PORT_1234_TCP=tcp://172.17.0.2:1234
CONTAINER1_PORT_1234_TCP_ADDR=172.17.0.2
CONTAINER1_PORT_1234_TCP_PORT=1234
CONTAINER1_PORT_1234_TCP_PROTO=tcp
CONTAINER1_NAME=/container2/container1
HOME=/root

docker 29.0.2: (5:29.0.2-1~ubuntu.22.04~jammy)

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=d2d80ab01a89
HOME=/root

tested on ubuntu 22.04 and 24.04 with the docker apt repository

docker version

Client: Docker Engine - Community
 Version:           29.0.2
 API version:       1.52
 Go version:        go1.25.4
 Git commit:        8108357
 Built:             Mon Nov 17 12:33:14 2025
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          29.0.2
  API version:      1.52 (minimum version 1.44)
  Go version:       go1.25.4
  Git commit:       e9ff10b
  Built:            Mon Nov 17 12:33:14 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v2.1.5
  GitCommit:        fcd43222d6b07379a4be9786bda52438f0dd16a1
 runc:
  Version:          1.3.3
  GitCommit:        v1.3.3-0-gd842d771
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client: Docker Engine - Community
 Version:    29.0.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.30.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.40.3
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 18
  Running: 6
  Paused: 0
  Stopped: 12
 Images: 137
 Server Version: 29.0.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Discovered Devices:
  cdi: nvidia.com/gpu=0
  cdi: nvidia.com/gpu=GPU-xxx
  cdi: nvidia.com/gpu=all
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2 nvidia
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: fcd43222d6b07379a4be9786bda52438f0dd16a1
 runc version: v1.3.3-0-gd842d771
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.8.0-87-generic
 Operating System: Ubuntu 22.04.5 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: xxxGiB
 Name: xxx
 ID: xxx
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: xxx
 Experimental: false
 Insecure Registries:
  nuc:5000
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false
 Firewall Backend: iptables

Additional Info

I understand the --link flag is a legacy feature, but the documentation only says it "may eventually be removed", and I didn't find any mention of changes on this documentation or the docker engine v29 release blog.

thomas-riccardi avatar Nov 20 '25 14:11 thomas-riccardi

It's outlined ih the deprecated features; https://docs.docker.com/engine/deprecated/#legacy-links-environment-variables and the release notes; https://docs.docker.com/engine/release-notes/29/#networking-2

thaJeztah avatar Nov 20 '25 15:11 thaJeztah

@thaJeztah

It's outlined ih the deprecated features; https://docs.docker.com/engine/deprecated/#legacy-links-environment-variables and the release notes; https://docs.docker.com/engine/release-notes/29/#networking-2

Oh, good to know! It would probably be useful to mention that directly in the feature documentation page, that's where I checked when our tools broke.

thomas-riccardi avatar Nov 20 '25 16:11 thomas-riccardi

cc @dvdksn

thaJeztah avatar Nov 20 '25 17:11 thaJeztah