How to run container using image id or name? - apache

I have created an apache server image from tar file using below command,
cat /home/ubuntu/docker-work/softwares/httpd-2.4.27.tar.gz | docker import - httpd:2.4
The image is created successfully and its name is httpd!
I have run below command,
docker run -d -p 80:80 --name=apache httpd:2.4
which is giving error,
docker: Error response from daemon: No command specified.
How do I run the above image using the name(httpd) ?

The error that you are getting means that the image import from the tar doesn't container a default command CMD line to start the container.
Docker allows you to not specify the CMD in the docker file, however in that case you need to provide the command when doing docker run. Example:
docker run -d -p 80:80 --name=apache httpd:2.4 httpd-foreground
Where httpd-foreground is the command that will start the httpd server process inside the container.

Related

docker container error "Failed to get D-Bus connection: Operation not permitted"

getting error"Failed to get D-Bus connection: Operation not permitted" while using systemctl command for restarting service in centos container.
use below command to start the docker container.
docker run -d -it --privileged ContainerId /usr/sbin/init
use docker file from below link for fix this issue. when run the docker image use --privileged.
https://hub.docker.com/_/centos
add these lines to docker file

Docker container cannot share data with host

I am running an automated test on a docker container that downloads a file as part of the test. The file ends up in the home/seluser/Download folder of the docker container. But I want to be ale to access it locally on my mac os x.
However, when I run the following command:
docker run -v /Users/MyUsername/Downloads/MappedFolder:/home/seluser/Downloads -d -P -p 4444:4444 selenium/standalone-chrome:3.7.1-beryllium
The downloaded files don't appear in either the docker container or the host.
As soon as I remove
-v /Users/MyUsername/Downloads/MappedFolder:/home/seluser/Downloads
and end up with
docker run -d -P -p 4444:4444 selenium/standalone-chrome:3.7.1-beryllium
the downloaded file shows up in the docker container
I can't seem to find a way to share that data with my host, so I can access the downloaded file in /Users/MyUsername/Downloads/MappedFolder
you are mounting /Users/MyUsername/Downloads/MappedFolder into docker container.
so it will overwrite the inside volume of docker container, so you can't see any files in the /home/seluser/Downloads directory, you can able to see data exst in host directory.
after running docker container.. you can able see all files whichever you download into /home/seluser/Downloads or in host directory

docker file to run automation test in JS files

I am trying to create a docker file to run selenium tests for a java script based project. Below is my docker file so far:
#base image
FROM selenium/standalone-chrome
#access to the project within docker container - Bundle app source
COPY ./seleniumTest/project /app
# Install Node.js
RUN sudo apt-get update
RUN sudo apt-get install --yes curl
RUN curl --silent --location https://deb.nodesource.com/setup_8.x | sudo bash -
#binding
EXPOSE 8080
#Define runtime
ENTRYPOINT /app/login.test.js
while running with $ docker run -p 4000:80 lamgadekamal/dockertest
returns: Unable to find image 'lamkam/dockertest:latest' locally docker: Error response from daemon: manifest for lamkam/dockertest:latest not found. Could not figure out why am I getting this?
I suspect that you need to build your image first, since the image cannot be found.
Run this command from the same directory where your Dockerfile is located. This will build the image.
docker build -t lamgadekamal/dockertest .
You can then verify that the image exists by running docker images
EDIT: After looking at this again, it appears that you are trying to run the wrong image. You are trying to run lamgadekamal/dockertest, but you built the image with the tag lamkam/dockertest? Seems like you have a typo. I would suggest running docker images to see exactly what is there, but in all likelihood, you need to run lamkam/dockertest.
docker run -p 4000:80 lamkam/dockertest

Add a link to docker run

I am making a test file. I need to have a docker image and run it like this:
docker run www.google.com
Everytime that url changes, I need to pass it into a file inside the docker. Is that possible?
Sure. You need a custom docker image but this is definitely possible.
Let's say you want to execute the command "ping -c 3" and pass it the parameter you send in the command line.
You can build a custom image with the following Dockerfile:
FROM alpine:latest
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT /entrypoint.sh
The entrypoint.sh file contains the following:
#!/bin/sh
ping -c 3 "$WEBSITE"
Then, you have to build you image by running:
docker build -t pinger .
Now, you can run your image with this command:
docker run --rm -e WEBSITE=www.google.com pinger
By changing the value of the WEBSITE env variable in the latest step you can get what you requested.
I just solved it by adding this:
--env="url=test"
to the docker run, but I guess your way of doing it, is better.
Thank you

Update all odoo modules in a docker container

I am working on a Odoo Docker container. I tried to find the appropriate command to update all the modules through the command line there but in vain. What is the appropriate command to do so ? I've put docker restart container_name -u all but also in vain.
Thanks in advance !
If you are using the docker-compose up command to start your servers, then you need to add the following line to your docker-compose.yml file under the odoo service:
command: odoo -u all -d odoo-prod
Where odoo-prod is the name of your database. This overwrites the default command (which is just odoo without update) and tells docker to update all modules when the container restarts.
Alternatively, you can also run a separate container that performs the updates:
docker run -v [your volumes] odoo:10.0 odoo -u all -d odoo-prod
This also overwrites the command from the dockerfile with the command stated here that includes the update.
You should have an ENTRYPOINT or CMD in your Dockerfile that runs python odoo.py -u all, the -u all option is for Odoo not docker restart
Open your container console
docker exec -it odoo bash
Update your module using other port
/usr/bin/odoo -p 8070 -d mydb -u mymodule
If the database it's on another container
/usr/bin/odoo -p 8070 --db_host=172.17.0.2 --db_user=odoo --db_password=odoo -d mydb -u mymodule