Can't acces apache on docker from my network - docker

I have this Dockerfile :
FROM ubuntu:20.04
EXPOSE 80
After installing apache2 package in the container I can't acces the default page of apache from the network. Also docker is in a virtual machine with debian 10. If I try the official apache image (https://hub.docker.com/_/httpd) everything works fine but I want to know why installing it manually doesn't work.
To build the container from the image I use this command :
sudo docker run --name ubuntu -p 80:80 -it ubuntu /bin/bash

I have run the exactly same test on my virtual centos machine and found working.
I've build the image using your dockerfile and run apache installation using below command.
docker build -t ubuntu
docker run --name ubuntu -p 80:80 -it ubuntu /bin/bash
and In terminal opened by the above mentioned command, i ran the below command.
apt-get update
apt-get install apache2
service apache2 start
After that opened another ssh terminal keeping the current running as i have not run the Ubuntu container in detached mode and checked by using.
docker ps -a
and found container is running with exposing 0.0.0.0:80 and checked
curl localhost
Please make sure you have not stoped docker container before running curl command or hit in the browser as its not run in detached mode or background.

Related

how to config autostart service[nginx] in a running docker container

my docker install my windows10 PC . the below step is which I created the container from the powershell window.
docker run -p 80 --name web -i -t ubuntu /bin/bash
#>apt-get update
#>apt-get install -y nginx
now, I found there are 2 questions when my pc restart.
the container 'web' is not running
when start 'web' container , the 'nginx' service is not running
the first question is resolved:
docker update --restart=always web
but the second question how to do? please help me
The best option in your case is running dedicated container for nginx instead of generic ubuntu with nginx being installed each time.
Use following command to run Nginx alpine release:
docker run -p 80 --name web-Nginx -d --restart always nginx:1.15.8-alpine

Starting Tomcat8 in docker doesnt work as in native ubuntu 16.04 environment

Following docker image starts tomcat8 in a fresh ubuntu 16.04 in a virtualbox but doesnt in a docker container. Is this a problem with docker, tomcat or am I missing on something?
Dockerfile:
FROM ubuntu:16.04
RUN apt update
RUN apt install -y openjdk-8-jdk
RUN apt-get install -y tomcat8
CMD service tomcat8 start
I assume that the image is built correctly (docker build command ends without errors)
While running the docker container just connect to it and check its logs:
docker logs <CONTAINER_ID> -f
You should see what happens there and why does tomcat fail to start. Maybe Java is not mapped correctly, maybe the ports are busy (unlikely but who knows).
And maybe tomcat starts correctly but you can't access it from outside because the 8080 port is not exposed / mapped (EXPOSE 8080 in docker file / -p 8080:8080 option while running a docker container)

Can't run Raspbian container on docker

So I've installed the hypriot OS for docker and I have tested it with ocker run -d -p 80:80 hypriot/rpi-busybox-httpd. All is well and the test works.
However, when I run docker run -i -t resin/rpi-raspbian to get raspbian nothing happens and docker ps shows no containers running. There are no error messages.
What is happening to my raspbian container?
Thanks
Running on Mac OSX and having downloaded the resin/rpi-raspbian image, I issue the command:
docker run -i -t resin/rpi-raspbian /bin/bash
which starts the container and puts me at the command prompt in raspbian.

How to install telnet in Docker for Windows 10

When I run telnet command in Docker it does not run.
Could you please tell me how to install telnet in Docker for Windows?
Old question I know but you can install telnet on docker for windows with the following in your dockerfile
RUN powershell -Command Add-WindowsFeature "telnet-client"
There is a docker image for it:
docker run mikesplain/telnet <host> <port>
If you are trying to telnet into your container to gain access to it, that isn't how you would want to connect. Docker provides that functionality.
Connect into a running container - Docs:
docker exec -it <container name> bash
$ root#665b4a1e17b6:/#
Start a container from image, and connect to it - Docs:
docker run -it <image name> bash
$ root#665b4a1e17b6:/#
Note: If it is an Alpine based image, it may not have Bash installed. In that case using sh instead of bash in your commands should work.
If you were using Kubernetes, you could install telnet in k8s by running:
apk update
apk add busybox-extras
telnet 10.0.180.37 11211
The following command will work if you want to install Telnet client in a running Windows Docker container. Just run this command in your container's terminal:
dism /online /Enable-Feature /FeatureName:TelnetClient

Why is Docker Tomcat failing to start?

I am trying to build a Tomcat image from a Dockerfile. This is what my Dockerfile looks like:
FROM dockerfile/java
RUN sudo apt-get update
RUN sudo apt-get install tomcat7
EXPOSE 8086
CMD sudo service tomcat7 start && tail -f /var/log/tomcat7/catalina.out.
but when I build an image from this and run the image with
$ docker run tomcat7-test
it gives the following:
Starting Tomcat servlet engine tomcat7 …fail!
I don’t know what is causing the problem. How can I check the logs of this Docker Tomcat? Can anybody tell me what commands I should use in the Dockerfile to run Tomcat?
There is an official Tomcat image you can use. There are links to the Dockerfiles there to checkout and install Tomcat.
If you want to inspect what is going on when you build your dockerfile, just perform the same steps (apt-getting tomcat7 and starting the service) manually after starting an interactive shell inside the dockerfile/java container with this command:
docker -it dockerfile/java bash
There you will be able to check the logs and see what could be going on.
I did install tomcat server in the docker container instead of using the official Tomcat image.
When I start the server I get the fail response but was curl the tomcat server index page.
Also instead of exiting the container, if you detach from it back to your terminal by typing:
ctrl-p then ctrl-q (source)
You can access your webapps from browser using the below URL:
http://<< boot2docker_ip >>:8080
Try running the image with following command
docker run -dt --cap-add SYS_PTRACE -p 8082:8080 tomcat7-test

Resources