Docker - Messing/Mixing/Duplicating application variables in memory inside running containers.
Tags: docker, container, memory
Published: 2021-12-28 19:57:39

<!--
This issue tracker is for *bug reports* and *feature requests*.
For questions, and getting help on using docker:

- Docker documentation - https://docs.docker.com
- Docker Forums - https://forums.docker.com
- Docker community Slack - https://dockercommunity.slack.com/ (register here: http://dockr.ly/community)
- Post a question on StackOverflow, using the Docker tag
-->

Hi!

I'm facing an issue with running docker containers by docker-compose. Before writing here, I tried all possible solutions, did research in google an so on. Still no luck! Hope, folks here can help me to figure out my issue related to docker running containers.

<!--
DO NOT report security issues publicly! If you suspect you discovered
a security issue, send your report privately to security@docker.com.
-->

### Expected behavior

Running 4 containers from same image
Application running in docker container generates random data and creates json string.
Each application running inside containers should generate/create unique values inside docker containers.

### Actual behavior

Running 4 containers from same image
Applications running inside docker containers mixing a values and almost 70% is the same value.
Assuming, issue with containers "shared" memory.
Same application(s) running outside of docker container works perfect and generates unique values.

Tested with PHP, Node.js, Golang. The issue is the same.

### Steps to reproduce the behavior

It's very complicated to reproduce the issue.
But in some words you can imagine: 

Without docker containers creation, running 4 copies of the same application: Generates unique random values.

Inside docker containers, applications running and 70% of values is the same.
Assuming, a problem comes from container's memory stack.

Using docker-compose to deploy containers:

all 4 containers using the same image

```
container A Using Image "Myimg"
container B Using Image "Myimg"
container C Using Image "Myimg"
container D Using Image "Myimg"
```

<!--
Describe the exact steps to reproduce. If possible, provide a *minimum*
reproduction example; take into account that others do not have access
to your private images, source code, and environment.

REMOVE SENSITIVE DATA BEFORE POSTING (replace those parts with "REDACTED")
-->

**Output of `docker version`:**

```
Docker version 20.10.12, build e91ed57
```

**Output of `docker info`:**

```
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.7.1-docker)
  scan: Docker Scan (Docker Inc., v0.12.0)

Server:
 Containers: 8
  Running: 6
  Paused: 0
  Stopped: 2
 Images: 41
 Server Version: 20.10.12
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  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 logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc version: v1.0.2-0-g52b36a2
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.13.0-22-generic
 Operating System: Ubuntu 21.10
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.54GiB
 Name: david-Macmini
 ID: FNY6:BSVD:L7JK:BFCW:ZCMP:6OMK:HM3I:U22T:WB2W:FCXM:4WC5:XS7B
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
```
**Running the docker in: Ubuntu 21.10 ( bare metal )**