I have created an Ubuntu virtual machine in Microsoft azure. I have installed docker on it and ran the Jenkins image through docker.
mkdir -p /var/jenkins_home
chown -R 1000:1000 /var/jenkins_home/
docker run -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -d --name jenkins jenkins/jenkins:lts
The container is running successfully but I am not able to access it in the browser.
link: http://publicip:8080
I have added an inbound rule to allow port:8080 and now I am able to open the Jenkins portal outside the host machine.
Related
How can I access files on a shared network drive from docker container?
I tried:
docker run --rm -it --name my_app -v //shared_drive_name:/opt/local/shared_drive my_app:1.0 /bin/bash
Also I tried method mentioned here: Docker add network drive as volume on windows
The directory /opt/local/shared_drive is created but empty. I tried different variations of slashes since the host is win and docker running linux. I am connected to the VPN from the host to access these drives.
I have this script for mounting Windows shared folders in Ubuntu Docker container. You have to copy the script in your image.
Then you should run the container, and after that call these commands:
docker exec container_name mkdir -p %shared folder inside docker path%
docker exec container_name /bin/bash /~path to your script~/mount_folder.sh %username% %password% %network_path% %docker_path%
For instance:
docker exec container_name /bin/bash /~path to your script~/mount_folder.sh "Admin" somePassword //192.168.7.1/shared_folder /data
Script is (mount_folder.sh):
#!/bin/bash
set -e
USERNAME=${1}
PASSWORD=${2}
NETWORK_PATH=${3}
DOCKER_PATH=${4}
mount -t cifs -o rw,username="${USERNAME}",password="${PASSWORD}",vers=3.0,nolock $NETWORK_PATH $DOCKER_PATH
Trying to learn container (Docker) by running an interactive mode on Azure (windows) VM. The problem is no matter what I've tried I'm stuck with this:
Service 'w3svc' has been stopped
Service 'w3svc' started
Following are info I think are relevant (please correct me if I'm wrong) and things I've tried:
According to Docker Hub here are the requirement to install Docker Desktop on Windows.
I think it meets the requirements:
The Azure (windows) VM is a D4s_v3; the important thing here is that it's a v3 ( that means it supports Hyper-V)
Was able to install Docker Desktop successfully and it's a Windows container:
Was successfully in pulling two Microsoft base images:
Have tried running these commands as Admin either in PowerShell or Command line:
docker run -it 1202696d4a85 cmd
docker run -it microsoft/iis cmd
docker run -it mcr.microsoft.com/windows/servercore/iis cmd
docker run -it 1202696d4a85 --entrypoint cmd
docker run -it microsoft/iis --entrypoint cmd
docker run -it mcr.microsoft.com/windows/servercore/iis --entrypoint cmd
and we're stuck with this:
However, these two commands:
docker run -it 755f6d13fa75 cmd
docker run -it 755f6d13fa75 --entrypoint cmd
we get this error that tells us that the host and container OS are not compatible:
Is this a misleading error? Thought "Windows Sever 2019 DataCenter" is Server Core? And if it's the Desktop Experience it would have specified?
Also, when creating the VM on Azure there's no 'Server Core' option:
So, what do we need to do so that we can run in interactive mode?
TIA!
[Update]
Based on the suggestions below created a new Azure Windows 10 Pro VM.
Ran these two commands:
docker run -it 1202696d4a85 cmd
docker run -it 1202696d4a85 --entrypoint cmd
Same issue.
I'm trying to deploy Apache Ignite Web console on Linux(CentOS 7), but to run docker, i have to set host_absolute_path of MongoDB, How to handle it?
<host_absolute_path> is a path on your host machine where MongoDB will create database files. This folder should be created before docker run. Go to Docker->Preferences->File Sharing and create the directory there or use the other way that suits your more.
Can anybody explain step by step?
docker run -d -p 80:80 -v <host_absolute_path>:/var/lib/mongodb --name web-console-standalone apacheignite/web-console-standalone
<host_absolute_path> is just a path on your local machine. MongoDB is embedded into the docker image. You need to specify a path where MongoDB will store data.
It's required because data need to survive restarts of the container. For example you can run:
docker run -it --rm -p 8080:80 -v /home/user/mongodb:/var/lib/mongodb apacheignite/web-console-standalone:2.7.0
It will run Web console 2.7.0 on 8080 port of the host machine and store data in /home/user/mongodb. This directory should be already present when you start the container.
For Windows:
something like below worked
docker run -d -p 80:80 -v D:\Softwares\IgniteProject\MangoDB:/var/lib/mongodb --name web-console-standalone apacheignite/web-console-standalone
I'm building a Docker image for an application which requires to ssh into localhost (i.e ssh user#localhost)
I'm working on a Ubuntu desktop machine and started with a basic ubuntu:16.04 container.
Following is the content of my Dockerfile:
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y \
openjdk-8-jdk \
ssh && \
groupadd -r custom_group && useradd -r -g custom_group -m user1
USER user1
RUN ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N "" && \
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
Then I build this container using the command:
docker build -t test-container .
And run it using:
docker run -it test-container
The container opens with the following prompt and the keys are generated correctly to enable ssh into localhost:
user1#0531c0f71e0a:/$
user1#0531c0f71e0a:/$ cd ~/.ssh/
user1#0531c0f71e0a:~/.ssh$ ls
authorized_keys id_rsa id_rsa.pub
Then ssh into localhost and greeted by the error:
user1#0531c0f71e0a:~$ ssh user1#localhost
ssh: connect to host localhost port 22: Cannot assign requested address
Is there anything I'm doing wrong or any additional network settings that needs to be configured? I just want to ssh into localhost within the running container.
First you need to install the ssh server in the image building script:
RUN sudo apt-get install -y openssh-server
Then you need to start the ssh server:
RUN sudo /etc/init.d/ssh start
or probably even in the last lines of the Dockerfile ( you must have one binary instantiated to keep the container running ... )
USER root
CMD [ "sh", "/etc/init.d/ssh", "start"]
on the host than
# init a container from an the image
run -d --name my-ssh-container-name-01 \
-v /opt/local/dir:/opt/container/dir my-image-01
As #user2915097 stated in the OP comments, this was due to the ssh instance in the container was attempting to connect to the host using IPv6.
Forcing connection over IPv4 using -4 solved the issue.
$ docker run -it ubuntu ssh -4 user#hostname
For Docker Compose I was able to add the following to my .yml file:
network_mode: "host"
I believe the equivalent in Docker is:
--net=host
Documentation:
https://docs.docker.com/compose/compose-file/compose-file-v3/#network_mode
https://docs.docker.com/network/#network-drivers
host: For standalone containers, remove network isolation between the
container and the Docker host, and use the host’s networking directly.
See use the host network.
I also faced this error today, here's how to fix it:
If(and only if) you are facing this error inside a running container that isn't in production.
Do this:
docker exec -it -u 0 [your container id here] /bin/bash
then when you entered the container in god mode, run this:
service ssh start
then you can run your ssh based commands.
Of course it is best practice to do it in your Dockerfile before all these, but no need to sweat if you are not done with your image built process just yet.
sudo docker run -p 3000:3000 -d --name mca-service myteam/reponame
this is the command i usually using to run the container. i have a folder in /var/log/appLog. i need to mount this directory with the contaner to store my app log file to make it persistent. i tried
sudo docker run -p 3000:3000 -d --name mca-service -v /var/log/appLog:/var/log/appLog:rw --entrypoint myteam/reponame
this command. but it raise some errors. can someone please help me to do this?
Under which user is your container (myteam/reponame) running? If it is not root, you have to change the user and group and the read/write permission of your folder on the host.
Your --entrypoint is empty. Either remove it or use --entrypoint []