I'm fairly new to Docker, and when attempting to install packages via the "Dockerfile" I've noticed that the build steps pass, but when i connect to the docker and load a shell, none of the packages have actually been installed.
Config:
FROM centos:latest
CMD yum -y install epel-release
CMD yum -y install collectd
Build steps:
Sending build context to Docker daemon 40.45 kB
Step 1/3 : FROM centos:latest
---> 67591570dd29
Step 2/3 : CMD yum -y install epel-release
---> Using cache
---> 4148233bce10
Step 3/3 : CMD yum -y install collectd
---> Using cache
---> 62998bf2ce0f
When connecting to the docker neither package is installed, but I am able to install the packages within the docker:
[root@cassiopeia monitoringDocker]# docker exec -it 0579169abb44 bash
[root@0579169abb44 /]# yum -y install epel-release
Loaded plugins: fastestmirror, ovl
base
Please help!
Use like
FROM centos:latest
RUN \
yum -y install epel-release && \
yum -y install collectd
OR
FROM centos:latest
RUN yum -y install epel-release collectd
RUN :
RUN instruction allows you to install your application and packages requited for it. It executes any commands on top of the current image and creates a new layer by committing the results.
CMD :
CMD instruction allows you to set a default command, which will be executed only when you run container without specifying a command. If Docker container runs with a command, the default command will be ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With