Where is /etc/default/docker file on Amazon Linux EC2 server? Where is /etc/default/docker file on Amazon Linux EC2 server? docker docker

Where is /etc/default/docker file on Amazon Linux EC2 server?


In Amazon linux (CentOS,Fedora,RedHat etc), you can find it in /etc/sysconfig/docker

You need to restart docker service once you update that file.

If you didn't find it, check if docker is installed in that machine. Its recommended to use ecs-optimized-ami for running docker containers.

More details: ECS Optimized AMI


Latest docker versions use /etc/docker/daemon.json for changing the daemon options. I would suggest to use this file instead of environment variables. Look at the below docker documentation for more details

https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file


Adding DOCKER_OPTS to /etc/sysconfig/docker will not work in Amazon Linux 2.

You will see this when watching the logs.

journalctl -u docker.serviceJan 17 08:11:07 portal-staging-new systemd[1]: Starting Docker Application Container Engine...Jan 17 08:11:07 portal-staging-new systemd[1]: Ignoring invalid environment assignment 'DOCKER_OPTS=Jan 17 08:11:07 portal-staging-new systemd[1]:     --cluster-advertise=eth0:2375Jan 17 08:11:07 portal-staging-new systemd[1]:     --cluster-store=consul://consul:8500Jan 17 08:11:07 portal-staging-new systemd[1]:     --host tcp://0.0.0.0:2375Jan 17 08:11:07 portal-staging-new systemd[1]:     --host unix:///var/run/docker.sockJan 17 08:11:07 portal-staging-new systemd[1]:     --log-driver=gelfJan 17 08:11:07 portal-staging-new systemd[1]:     --log-opt gelf-address=udp://127.0.0.1:1513Jan 17 08:11:07 portal-staging-new systemd[1]:     --log-opt tag=dockerJan 17 08:11:07 portal-staging-new systemd[1]:     --userland-proxy=falseJan 17 08:11:07 portal-staging-new systemd[1]: ': /etc/sysconfig/docker

So you will need to add the config to /etc/docker/daemon.json.