/root/compile: line 2: $'\r': command not found
The above means you need to dos2unix
the file.
# change permissions on the compile script
RUN chmod +x /root/compile.sh
# test out compile command
RUN /bin/bash -c "source /root/compile.sh"
For example, if you have a custom configuration file, in the assets
folder and you want to copy and overwrite a system configuration, use the COPY
command inside the Dockerfile
:
COPY assets/configuration.conf /etc/configuration.conf
The argument -it
means run in interactive mode (hence the -i
) and allocate a pseudo-TTY (TTY means "teletypewriter", hence the -t
). Teletypewriter mode allows one to send inputs to the container.
docker exec -it <CONTAINER NAME> sh
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
# Delete every Docker containers
# Must be run first because images are attached to containers
docker rm -f $(docker ps -a -q)
# Delete every Docker image
docker rmi -f $(docker images -q)
First create your own docker network:
docker network create --subnet=172.19.0.0/16 <NETWORK NAME>
The subnet
can be any IP address that does not conflict with any other IP address. I just used 172.19.0.0/16
as an example.
Use any name to name the <NETWORK NAME>
.
Next, run your Dockerfile with the created network:
docker run --net <NETWORK NAME> --ip 172.19.0.22 -it <CONTAINER NAME> bash
To achieve this, you need to change the DNS settings of the Docker daemon. You can set the default options for the docker daemon by creating a daemon configuration file at /etc/docker/daemon.json
.
You should create this file with the following contents to set two DNS, firstly your network’s DNS server, and secondly the Google DNS server to fall back to in case that server isn’t available:
/etc/docker/daemon.json
:
{
"dns": ["10.0.0.2", "8.8.8.8"]
}
Then restart the docker service:
sudo service docker restart
yum --showduplicates list <PACKAGE>| expand