I build the Docker based on Ubuntu 16 and want to allow PuTTY access to the Ubuntu.
I have added the line to the docker file:
#Download base image ubuntu 16.04
FROM ubuntu:16.04
# Update Software repository
RUN apt-get update
# Install nginx, php-fpm and supervisord from ubuntu repository
RUN apt-get install -y nginx php7.0-fpm supervisor && \
rm -rf /var/lib/apt/lists/*
RUN apt-get autoclean -y supervisor
RUN apt-get install openssh-server -y supervisor
But when I build the image it gives me
Step 5/18 : RUN apt-get install openssh-server -y supervisor --->
Running in c9425deece29 Reading package lists... Building dependency
tree... Reading state information... E: Unable to locate package
openssh-server
How to fix it? My task is: to allow connection from a host (Windows) to the docker container via PuTTY.
Following Dockerfile should work.
#Download base image ubuntu 16.04
FROM ubuntu:16.04
# Update Software repository
RUN apt-get update && \
apt-get upgrade -y
RUN apt-get install openssh-server -y supervisor
# Install nginx, php-fpm and supervisord from ubuntu repository
RUN apt-get install -y nginx php7.0-fpm supervisor && \
rm -rf /var/lib/apt/lists/*
RUN apt-get autoclean -y supervisor
There is two thing it seems problematic to me.
After update I'm always using upgrade to update all packages on my system. It's not necessary but I find it's a good practice
You are removing /var/lib/apt/lists/ * then you are trying to install openssh-server. apt can't find anything on that path when it need.
Related
I am new to dokers. I need jenkins and jupyter notebook in the same container. I have written the following Dockerfile but I can't access localhost:8888 or 8080 or 50000 when I run this image. However, these ports work very well when I run the official jenkins image. So, I don't know where I am making the mistake in my Dockerfile.
# using ubuntu as base image
FROM ubuntu:20.04
# installing python version 3.8
RUN apt-get update -y \
&& apt-get install -y apt-utils \
&& apt-get install python3.8 -y
# installing jupyter notebook
RUN apt-get install jupyter -y
EXPOSE 8888
# installing jenkins
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install dialog apt-utils -y
RUN apt-get update && apt-get install -y gnupg2
RUN apt-get install -y wget
RUN wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | apt-key add -
RUN sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list'
RUN apt-get update
RUN apt-get install jenkins -y
EXPOSE 50000 8080
# removing unnecessary files
RUN rm -rf /var/lib/apt/lists/*
COPY sample.py .
LABEL maintainer=Ammar
CMD ["bash"]
I started studying docker recently and wanted to install php, apache and postgres in a ubuntu base image. But cannot run it after build.
Here is my Dockerfile
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get -qq -y install curl
RUN apt-get -y install apache2
RUN apt-get -y install php7.0
RUN apt-get -y install libapache2-mod-php7.0
RUN apt-get -y install php7.0-mysql
RUN apt-get -y install php7.0-pgsql
RUN apt-get -y install php7.0-gd
RUN apt-get -y install php-pear
RUN apt-get -y install php7.0-curl
COPY . /var/www/html
EXPOSE 80
Can you please help me?
Thanks.
there are several issues here. First of all, I have the impression that you're mixing up docker and virtual machines. For this I suggest to go and read what are the differences.
Concerning your question, the problem is that the base image (ubuntu:16.04) has CMD bash (or something similar, I really didn't check) and therefore php is not considered.
In order to start apache, you should append the following:
CMD . /etc/apache2/envvars && /usr/sbin/apache2ctl -DFOREGROUND
Anyway, I'd suggest you give a check to the php official image.
I am trying to use a node agent container in Jenkins to run npm instructions on it. So that, I am creating a Dockerfile to get a valid image with ssh and nodejs. The executor runs fine, but when I use npm it says that it doesn't know the command.
The same problem happens when (after building the dockerfile) I do docker exec -it af5451297d85 bash and after that, inside the container, I try to do npm --v (for example).
# This Dockerfile is used to build an image containing an node jenkins agent
FROM node:9.0
MAINTAINER Estefania Castro <estefania.castro#luceit.es>
# Upgrade and Install packages
RUN apt-get update && apt-get -y upgrade && apt-get install -y git openssh-server
# Install NGINX to test.
RUN apt-get install nginx -y
# Prepare container for ssh
RUN mkdir /var/run/sshd && adduser --quiet jenkins && echo "jenkins:jenkins" | chpasswd
RUN npm install
ENV CI=true
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
I would like to run npm instructions like npm install, npm publish, ... to manage my project in a jenkinsfile. Could anyone help?
Thanks
I have already solved the problem (after two weeks haha).
FROM jenkins/ssh-slave
# Install selected extensions and other stuff
RUN apt-get update && apt-get -y --no-install-recommends install && apt-get clean
RUN apt-get install -y curl
# Install nodejs
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install -y nodejs && apt-get install -y nginx
I'm bulding nginx in a Debian-based docker image. Every time I run it, it shows me the current nginx version nginx/1.10.3. I need it to download the latest stable nginx.
This is my Dockerfile:
FROM debian:latest
RUN apt-get -y update
RUN apt-get install -yq gnupg2
RUN apt-get install -yq software-properties-common
RUN apt-get install -yq lsb-release
RUN apt-get install -yq curl
RUN add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
RUN add-apt-repository "deb http://nginx.org/packages/debian `lsb_release -cs` nginx"
RUN apt-get install -y nginx
RUN rm -rf /var/lib/apt/lists/
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
EXPOSE 80
CMD ["/usr/sbin/nginx"]
Docker image layers serve as a cache for subsequent builds. Without some sort of change in the Dockerfile, you're likely getting nginx 1.10.3 because it was cached from a previous build.
Instead of building your own nginx image, you should use the official nginx image, and choose the tag (e.g., 1.15.9) for the version you want.
First off, trivially, you need to apt-get update to fetch the index files from the repos you added before apt will find any packages there.
RUN add-apt-repository blah blah
RUN apt-get update -y # Add this
RUN apt-get install -y whatever
But also, you have invalid repos in the add-apt-repository section. The output of lsb_release -sc is a Debian code name like stretch which of course the Canonical partner repo doesn't have a section for; and the NGninx repo only supports Debian squeeze (though I would expect the packages to also work on newer versions of Debian).
Finally, you need to manage the keys of these repos, or otherwise mark them as safe. As a small bonus, I tried to condense your apt-get downloads slightly. Try this Dockerfile:
FROM debian:latest
RUN apt-get -y update
RUN apt-get install -yq gnupg2 \
software-properties-common curl # lsb-release
# XXX FIXME: the use of [trusted=yes] is really quick and dirty
RUN add-apt-repository "deb [trusted=yes] http://archive.canonical.com/ bionic partner"
RUN add-apt-repository "deb [trusted=yes] http://nginx.org/packages/debian squeeze nginx"
RUN apt-get update -y
RUN apt-get install -y nginx
RUN rm -rf /var/lib/apt/lists/
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
EXPOSE 80
CMD ["/usr/sbin/nginx"]
I'm trying to get a rails server setup on a raspberry pi by building a Docker image.
Image:
FROM ruby:latest
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN apt-get install -y nodejs
WORKDIR /webapp
COPY Gemfile* /webapp
RUN bundle install
COPY . /webapp/
CMD ["rails", "s", "-b", "0.0.0.0"]
But I'm getting
E: Package 'nodejs' has no installation candidate
EDIT:
I have tried adding the command from the nodejs site curl -sL https://deb.nodesource.com/setup_10.x | bash - && apt-get install -y nodejs
The reason the error Package 'nodejs' has no installation candidate was showing up regardless of how you tried to add the repo to apt-get is because Skipping acquire of configured file 'main/binary-armel/Packages' as repository 'https://deb.nodesource.com/node_10.x stretch InRelease' doesn't support architecture 'armel'.
My solution was to move to an arm32v7/ruby base image and running the same commands. This will install the nodejs_4.8.2~dfsg-1_armhf.deb package which is compatible with the arm architecture.