Trying to build this Dockerfile:
FROM dockerfile/ubuntu
RUN apt-get update && apt-get install -y apache2
COPY proxypass.conf /etc/apache2/sites-available
COPY caching.conf /etc/apache2/conf-available
RUN a2ensite proxypass \
&& a2enconf caching \
&& a2disconf serve-cgi-bin
EXPOSE 80
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
The proxypass.conf
and caching.conf
files are located in the apache
directory along with the Dockerfile
.
Running docker build
gives this output:
$ sudo docker build -t me/apache apache
Sending build context to Docker daemon 29.7 kB
Sending build context to Docker daemon
Step 0 : FROM dockerfile/ubuntu
---> 77f8745ed183
Step 1 : RUN apt-get update && apt-get install -y apache2
---> Using cache
---> d62d92d91591
Step 2 : COPY proxypass.conf /etc/apache2/sites-available
2014/10/16 09:02:32 lchown /u01/docker/devicemapper/mnt/38bcd5cca695b4e9ac9af77e0342f85dea9fb10a238f7bd5173289bb956cf5c8/rootfs/etc/apache2/sites-available/proxypass.conf: not a directory
This is Oracle Linux 6.5 (essentially CentOS 6.5).
$ sudo docker info
Containers: 1
Images: 113
Storage Driver: devicemapper
Pool Name: docker-8:2-1308404-pool
Data file: /u01/docker/devicemapper/devicemapper/data
Metadata file: /u01/docker/devicemapper/devicemapper/metadata
Data Space Used: 4307.1 Mb
Data Space Total: 102400.0 Mb
Metadata Space Used: 5.5 Mb
Metadata Space Total: 2048.0 Mb
Execution Driver: native-0.2
Kernel Version: 2.6.32-358.23.2.el6.x86_64
Username: kgutwin
Registry: [https://index.docker.io/v1/]
Docker Dockerfiles COPY Instruction The COPY instruction copies new files or directories from <src> and adds them to the filesystem of the container at the path <dest> . Multiple <src> resource may be specified but they must be relative to the source directory that is being built (the context of the build).
No. WORKDIR affects the working directory inside the container.
It turns out that you cannot include files outside Docker's build context. However, you can copy files from the Dockerfile's parent directory.
the documentation for the Dockerfile COPY instruction says:
If <dest> does not end with a trailing slash, it will be considered a regular file and the contents of <src> will be written at .
So just add a /
for the destination directories and you will be able to build your image:
COPY proxypass.conf /etc/apache2/sites-available/
COPY caching.conf /etc/apache2/conf-available/
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