My linux world » Docker build APP

Docker build APP


Contents

First create the file names ‘Dockerfile’

# Use an official image of centos
FROM centos

# Set the working directory to /opt/docker
WORKDIR /opt/docker

# Copy the current directory contents into the container at /opt/docker
ADD . /opt/docker

# Install any needed packages
RUN yum -y install epel-release

# Define environment variable
ENV MYENVVAR my-env-value

# Run shell when the container launches
CMD ["/bin/bash"]

Build new container

docker build -t newcontainername .

Now you can access to it

docker run -it newcontainername

If you can to update the MYENVVAR value

docker run -e MYENVVAR='new value' -it newcontainername
 
[root@dcf332ea87ae docker]# echo $MYENVVAR
new value

Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.