View container cpu limits

docker version
Client:
Version: 17.03.2-ee-4
API version: 1.27
Go version: go1.7.5
Git commit: 1e6d71e
Built: Fri May 19 20:19:32 2017
OS/Arch: linux/amd64

Server:
Version: 17.03.2-ee-4
API version: 1.27 (minimum version 1.12)
Go version: go1.7.5
Git commit: 1e6d71e
Built: Fri May 19 20:19:32 2017
OS/Arch: linux/amd64
Experimental: false

docker-compose.yml
version: ‘3’

services:
apache:
image: "registry.x.y.z/lob/product/apache:1.0-SNAPSHOT"
tty: true
ports:
- “80:80”
- "443:443"
depends_on:
- node2
networks:
- my_network
deploy:
replicas: 1
resources:
limits:
memory: 4G
cpus: “2.0”

I am attempting to perform a docker stack deploy and limit my container’s memory to 4G and maximum number of cpus to 2. The yaml file is above showing my syntax. When try to view the resource limits using docker stats, however, I am only able to see the maximum amount of memory allocated. i.e:
docker stats
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
adecb78a325e 0.00% 25.11 MiB / 4 GiB 0.61% 1.3 kB / 1.94 kB 17.3 MB / 0 B 56
I also installed cAdvisor, but it shows
Isolation

CPU
Shares 1024 shares
Allowed Cores 0 1 2 3

Memory
Reservation unlimited
Limit 4.00 GB
Swap Limit 8.00 GB

Is my syntax incorrect?
Is there a way to view the maximum number of cpus allocated to a container?
Thank you,
Anthony

The setting is fine.

Keep in mind you are in a shared kernel so you will may see more than you can use, as the kernel shows you what is installed to the machine, not what is available to your process.

For more details check the official guide: