I am new to Docker and trying to build Docker image. I simply created Docker file but getting some error not able to identify how to resolve this.
My Docker file code is:
FROM ubuntu
MAINTAINER ravat
RUN echo “Hello Apache server on Ubuntu Docker” > /home/ravata/Desktop/DockerDemo/index.html
CMD [ "/bin/bash" ]
the error I am getting is:
/bin/sh: 1: cannot create /home/ravata/Desktop/DockerDemo/index.html: Directory nonexistent
Not sure why are you trying to create the file at this specific location, but as error hints you, you need to create a folder you'd like to put your file first, e.g.
FROM ubuntu
MAINTAINER ravat
RUN mkdir -p /home/ravata/Desktop/DockerDemo/
RUN echo “Hello Apache server on Ubuntu Docker” > /home/ravata/Desktop/DockerDemo/index.html
CMD [ "/bin/bash" ]
Just to make it clear, the reason you do not have home folder for username ravata is the fact that no such user exists on brand new ubuntu docker image.
The error message tells you why, /home/ravata/Desktop/DockerDemo/ directory doesn't exists.
You should first create it.
Note that this file will be created inside your container, not on your computer. So directory should be created inside the container, for example with a RUN mkdir ...
Related
I created a docker image using a script. The docker image got created successfully but when I am trying to run on the browser, I get the following message
I tried to resolve the error using webapps but it is popping up the same message.
It is happening probably because the directory /usr/local/tomcat/webapps is empty. as you can see in the description in the Docker Hub official image:
You can then go to http://localhost:8888 or http://host-ip:8888 in a browser (noting that it will return a 404 since there are no webapps loaded by default).
To solve that, you can just create a new image and copy and paste what you want inside of the folder /usr/local/tomcat/webapps.
For example, you can find inside of the folder /usr/local/tomcat/webapps.dist files of the tomcat webapp manager. If you try to see what is that you can run:
$ docker run -it tomcat:10 ls /usr/local/tomcat/webapps.dist
ROOT docs examples host-manager manager
Now that you know what is inside of the folder /usr/local/tomcat/webapps.dist, create your own Dockerfile and copy and paste this folder to /usr/local/tomcat/webapps:
FROM tomcat
RUN cp -R /usr/local/tomcat/webapps.dist/* /usr/local/tomcat/webapps
CMD ["catalina.sh", "run"]
Build the image:
$ docker build . -t custom-tomcat
Execute the image:
$ docker run -d -P custom-tomcat
Check the port opened:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
58390eab3fec custom-tomcat "catalina.sh run" 9 minutes ago Up 9 minutes 0.0.0.0:49163->8080/tcp, :::49163->8080/tcp lucid_joliot
Open your browser and check if it works:
I am running an application with a dockerfile that I made.
I run at first my image with this command:
docker run -it -p 8501:8501 99aa9d3b7cc1
Everything works fine, but I was expecting to see a file in a specific folder of my directory of the app, which is an expected behaviour. But running with docker, seems like the application cannot write in my host directory.
Then I tried to mount a volume with this command
docker 99aa9d3b7cc1:/output .
I got this error docker: invalid reference format.
Which is the right way to persist the data that the application generates?
Use docker bind mounts.
e.g.
-v "$(pwd)"/volume:/output
The files created in /output in the container will be accessible in the volume folder relative to where the docker command has been run.
I am a beginner in docker and I am trying to run a Q&A website locally in my browser. I have found an open source container on the link https://hub.docker.com/r/zout84/askbot-docker. Here are the steps that I have done:
I have downloaded docker toolbox DockerToolbox-19.03.1.exe to be able to run docker using my Windows terminal.
Following the instructions on the above link I have run the command docker run -v /tmp/askbot:/data/ -p 8080:80 -d zout84/askbot-docker. Since I am on Windows I have replaced /tmp/askbot:/data/ by a folder I have created.
I have downloaded the container and put it a local folder that I called Docker_source. I have replaced zout84/askbot-docker by C:\Docker_source in the above docker run command
Now the error that I have is docker: invalid reference format: repository name must be lowercase.
Please, any suggestions on how to make it work?
Like the error said, The repository has to be lower case. It is called C:\Docker_source. You got a capital "D" over there. change it to a "d"
I'm new to docker and am trying to bind mount a folder in my docker container with a folder on my local machine. Using the code below, I was able to create the container with no issue.
docker run -it -v /Users/bdbot/Documents/mount_demo/:/mount_demo nycdsa/linux-toolkits bash
However, when I tried to create a txt file within the container folder, I got this error:
bash: demo.txt: Permission denied
Seeing that it was an access issue, I ran
sudo chmod 777 ../mount_demo
This allowed me to create the file, however when I checked the folder on my local machine it was not there. So the folders are not syncing.
I've also made sure the docker settings "Shared Drives" had the correct credentials. I'm not familiar enough with Docker to know how to trouble shoot further and have not been able to find anything online. I am using Windows, and everything is up to date.
The answer ended up being a really simple fix. The combination of using unix on a windows machine required that I add an additional slash(/) before the folder path. The below fixed this issue for me:
docker run -it -v //Users/bdbot/Documents/mount_demo/:/mount_demo nycdsa/linux-toolkits bash
I am building dockerfile to create an image where I want to build a package. I want to pull this package inside the docker image. I need to do a git clone for that. I saw the discussion on this post :
Using SSH keys inside docker container
Based on that, here is the content in my Dockerfile :
ENV SSH_HOME /Users/myid
ADD $SSH_HOME/.ssh/id_rsa /root/.ssh/id_rsa
RUN echo " IdentityFile ~/.ssh/id_rsa" >> /etc/ssh/ssh_config
When I run docker build, I am getting an error due to relative path. If I provide absolute path, it says the location is outside of context. Any idea how to fix this? I am running on Mac OSX 10.
With the script above, I am getting the following error :
ADD failed: stat /var/lib/docker/tmp/docker-builder6164655/Users/myid/.ssh/id_rsa: no such file or directory
Looks like it might be related to this bug here
The broken example is very similar to your path problem:
# Dockerfile
FROM ubuntu:14.04
COPY start.sh /start.sh
# comes back with:
stat /var/lib/docker/aufs/mnt/e89417ccaafbc91c3f930b56819427f83b3f2d3b3a246fbd6b48c9abcc7233f6/start.sh: no such file or directory
I'd try
updating to the most recent docker
restarting your docker engine